Produced by Araxis Merge on 5/8/2017 10:03:28 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-utility-web-Release-1.0.0-Branch.zip\var-utility-web-Release-1.0.0-Branch\acceptance-tests\watir-ruby\module\database | MongoUtility.rb | Wed Jan 25 20:20:12 2017 UTC |
| 2 | var-utility-web-Release-1.0.0-Branch.zip\var-utility-web-Release-1.0.0-Branch\acceptance-tests\watir-ruby\module\database | MongoUtility.rb | Mon May 8 13:01:31 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 372 |
| 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 ' bson' | |
| 3 | require 'a ctive_supp ort/time' | |
| 4 | include Mo ngo | |
| 5 | ||
| 6 | module Mon goUtility | |
| 7 | ||
| 8 | MONGO_URI = "mongodb ://var-uti lity:var-u tility@ IP /var-utili ty?ssl=tru e&connectT imeoutMS=2 0000&authM echanism=S CRAM-SHA-1 &" | |
| 9 | ||
| 10 | def conn ectToMongo DB(dbName) | |
| 11 | db = M ongo::Clie nt.new(MON GO_URI, :s sl_verify => true, : ssl_ca_cer t => 'modu le/databas e/mongodb- cert.crt' ) | |
| 12 | #db = Mongo::Con nection.ne w(MONGO_HO ST, MONGO_ PORT).db(d bName) | |
| 13 | return db | |
| 14 | end | |
| 15 | ||
| 16 | def remo veCollecti on(collect ionName,db ) | |
| 17 | collec tion = db[ collection Name] | |
| 18 | collec tion.drop | |
| 19 | end | |
| 20 | ||
| 21 | def upda teDocument (collectio nName, obj Id, column Name, valu e, db) | |
| 22 | collec tion = db[ collection Name] | |
| 23 | collec tion.updat e_one({:_i d => objId }, {"$set" => {colum nName => v alue}}) | |
| 24 | ||
| 25 | end | |
| 26 | ||
| 27 | def remo veDocument (collectio nName, obj Id, db) | |
| 28 | collec tion = db[ collection Name] | |
| 29 | collec tion.remov e({:_id => objId}) | |
| 30 | ||
| 31 | end | |
| 32 | ||
| 33 | ||
| 34 | def rest oreCollect ion(collec tionName, dbName, fi leName, db ) | |
| 35 | remove Collection (collectio nName, db) | |
| 36 | ||
| 37 | begin | |
| 38 | snap shot fileN ame, :host => MONGO_H OST, :port => MONGO_P ORT, :db = > dbName, :collectio n => colle ctionName, :path => 'spec/snap shots' | |
| 39 | puts "[insertC ollection] imported Collection " + colle ctionName | |
| 40 | ||
| 41 | rescue Exception =>e | |
| 42 | puts "[Excepti on insertC ollection] " + e.to_s | |
| 43 | end | |
| 44 | ||
| 45 | end | |
| 46 | ||
| 47 | def inse rtDocument (collectio nName, doc ument, db) | |
| 48 | collec tion = db[ collection Name] | |
| 49 | result = collect ion.insert _one(docum ent) | |
| 50 | #resul t.n => ret urns 1, be cause 1 do cument was inserted. | |
| 51 | return result.n | |
| 52 | end | |
| 53 | ||
| 54 | def inse rtManyDocu ments(coll ectionName , document s, db) | |
| 55 | collec tion = db[ collection Name] | |
| 56 | ||
| 57 | =begin | |
| 58 | #docum ents sampl e | |
| 59 | docume nts = [ | |
| 60 | { :name => ' Flying Lot us' }, | |
| 61 | { :name => ' Aphex Twin ' } | |
| 62 | ] | |
| 63 | =end | |
| 64 | result = collect ion.insert _many(docu ments) | |
| 65 | ||
| 66 | ||
| 67 | #resul t.n #=> re turns 2, i f 2 docume nts were i nserted. | |
| 68 | return result.n | |
| 69 | ||
| 70 | end | |
| 71 | ||
| 72 | def getF ieldByObjI d(collecti onName, ob jId, colum nName, db) | |
| 73 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
| 74 | #=> Yields a B SON::Docum ent. | |
| 75 | #put s "getFiel dByObjId: " + docum ent.to_s | |
| 76 | retu rn documen t[columnNa me] | |
| 77 | end | |
| 78 | end | |
| 79 | ||
| 80 | def getN thCoreSett ings(colle ctionName, objId, nt h, db) | |
| 81 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
| 82 | core Settings = document[ 'coreSetti ngs'] | |
| 83 | retu rn coreSet tings[nth] | |
| 84 | end | |
| 85 | end | |
| 86 | ||
| 87 | def getN thRequestS ettings(co llectionNa me, objId, nth, db) | |
| 88 | db[col lectionNam e].find({: _id => obj Id}).each do |docume nt| | |
| 89 | core Settings = document[ 'requestSe ttings'] | |
| 90 | retu rn coreSet tings[nth] | |
| 91 | end | |
| 92 | end | |
| 93 | ||
| 94 | def getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
| 95 | db[col lectionNam e].find({: _id => obj Id}, :fiel ds => [col umnName]). each do |d ocument| | |
| 96 | ||
| 97 | retu rn documen t['coreSet tings'] | |
| 98 | end | |
| 99 | end | |
| 100 | ||
| 101 | def getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
| 102 | db[col lectionNam e].find({: _id => obj Id}, :fiel ds => [col umnName]). each do |d ocument| | |
| 103 | ||
| 104 | retu rn documen t['request Settings'] | |
| 105 | end | |
| 106 | end | |
| 107 | ||
| 108 | def veri fyNotifica tionDelete d(collecti onName, ob jId, colum nName, db) | |
| 109 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
| 110 | isDele ted = true | |
| 111 | ||
| 112 | for re cord in do cument | |
| 113 | if r ecord[colu mnName] == false | |
| 114 | is Deleted = false | |
| 115 | br eak | |
| 116 | end | |
| 117 | end | |
| 118 | #puts "[verifyNo tification Deleted ] objId: " + objId + " - columnN ame: " + c olumnName + " IsDele ted: " + i sDeleted.t o_s | |
| 119 | return isDeleted | |
| 120 | ||
| 121 | end | |
| 122 | ||
| 123 | def veri fyDocument sDeleted(c ollectionN ame, objId , columnNa me, db) | |
| 124 | docume nt = getD ocumentByO bjId(colle ctionName, objId, co lumnName, db) | |
| 125 | isDele ted = true | |
| 126 | ||
| 127 | for re cord in do cument | |
| 128 | #put s "record[ columnName ] = " + re cord[colum nName].to_ s | |
| 129 | ||
| 130 | if r ecord[colu mnName] == false | |
| 131 | is Deleted = false | |
| 132 | br eak | |
| 133 | end | |
| 134 | end | |
| 135 | ||
| 136 | return isDeleted | |
| 137 | ||
| 138 | end | |
| 139 | ||
| 140 | def retr ieveThisFi eldInDocum entWithMul tiRows(col lectionNam e, objId, columnNam e, db) | |
| 141 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
| 142 | outPut = "" | |
| 143 | docume nt.each { |record| | |
| 144 | #put s record[c olumnName] | |
| 145 | if r ecord[colu mnName] != nil then | |
| 146 | ou tPut = rec ord[column Name] + ', ' + outPut .to_s | |
| 147 | else | |
| 148 | ou tput = "" + "," + ou tput.to_s | |
| 149 | end | |
| 150 | } | |
| 151 | #puts "outPut=" + outPut.t o_s | |
| 152 | return outPut | |
| 153 | ||
| 154 | end | |
| 155 | ||
| 156 | def retr ieveThisFi eldInDocum entWithMul tiRowsAsAr ray(collec tionName, objId, co lumnName, db) | |
| 157 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
| 158 | outPut = Array.n ew | |
| 159 | docume nt.each { |record| | |
| 160 | if r ecord[colu mnName] != nil then | |
| 161 | ou tPut.push( record[col umnName]) | |
| 162 | end | |
| 163 | } | |
| 164 | return outPut | |
| 165 | end | |
| 166 | ||
| 167 | def retr ieveThisFi eldInDocum ent(collec tionName, objId, co lumnName, db) | |
| 168 | docume nt = getDo cumentByOb jId(collec tionName, objId, col umnName, d b) | |
| 169 | ||
| 170 | for re cord in do cument | |
| 171 | puts "record[c olumnName] =" + recor d[columnNa me].to_s | |
| 172 | retu rn record[ columnName ] | |
| 173 | end | |
| 174 | end | |
| 175 | ||
| 176 | def retr eiveAllDoc umentsInCo llection(c ollectionN ame, db) | |
| 177 | docume ntArray = [] | |
| 178 | ||
| 179 | db[col lectionNam e].find(). each do |d ocument| | |
| 180 | docu mentArray << documen t | |
| 181 | end | |
| 182 | ||
| 183 | puts d ocumentArr ay.to_s | |
| 184 | ||
| 185 | return documentA rray | |
| 186 | end | |
| 187 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.