def searchCodeReviews(self, crStruct): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE " queryPart = self.createORLoop(dbEscape(crStruct.Name), "Name") if len(queryPart) != 0: query = query + "(" + queryPart + ") AND " query = query + "Author LIKE '%" + dbEscape(crStruct.Author) + "%' AND Status LIKE '%" + dbEscape(crStruct.Status) + "%' AND DateCreate >= '" + crStruct.DateCreate + "'" return self.execCodeReviewQuery(query, False)
def getVotesByID(self, type, id): query = "SELECT Count(Reviewer) FROM Reviewers WHERE IDReview = '" + dbEscape( id) + "' AND Vote = '" + dbEscape(type) + "'" cursor = self.db.cursor() cursor.execute(query) row = cursor.fetchone() if not row: return 0 return row[0]
def searchCodeReviews(self, crStruct): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE " queryPart = self.createORLoop(dbEscape(crStruct.Name), "Name") if len(queryPart) != 0: query = query + "(" + queryPart + ") AND " query = query + "Author LIKE '%" + dbEscape( crStruct.Author) + "%' AND Status LIKE '%" + dbEscape( crStruct.Status ) + "%' AND DateCreate >= '" + crStruct.DateCreate + "'" return self.execCodeReviewQuery(query, False)
def save(self, db): query = "" cursor = db.cursor() #Add information to a new database entry if self.IDReview == "": query = "INSERT INTO CodeReviews VALUES(NULL,'" + dbEscape( self.Author) + "','" + dbEscape( self.Status ) + "','" + ` self.DateCreate ` + "','" + dbEscape( self.Name) + "','" + dbEscape(self.Notes) + "')" cursor.execute(query) db.commit() cursor.execute("SELECT last_insert_rowid() FROM CodeReviews") self.IDReview = ` cursor.fetchone()[0] ` else: #Update information in existing database entry query = "UPDATE CodeReviews SET Author = '" + dbEscape( self.Author ) + "', Status = '" + dbEscape( self.Status ) + "', DateCreate = '" + ` self.DateCreate ` + "', Name = '" + dbEscape( self.Name) + "', Notes = '" + dbEscape( self.Notes) + "' WHERE IDReview = '" + dbEscape( self.IDReview) + "'" cursor.execute(query) db.commit() return self.IDReview
def save(self, db): #Add information to a new database entry query = "INSERT INTO Reviewers VALUES('" + dbEscape(self.IDReview) + "', '" + dbEscape(self.Reviewer) + "','" + dbEscape(self.Status) + "','" + dbEscape(self.Vote) + "')" cursor = db.cursor(); try: cursor.execute(query) db.commit() except: #Update information in existing database entry query = "UPDATE Reviewers SET Status = '" + dbEscape(self.Status) + "', Vote = '" + dbEscape(self.Vote) + "' WHERE IDReview = '" + dbEscape(self.IDReview) + "' AND Reviewer = '" + dbEscape(self.Reviewer) + "'" cursor.execute(query) db.commit()
def save(self, db): cursor = db.cursor() if self.IDFile == "": #Add information to a new database entry query = "INSERT INTO ReviewFiles VALUES(NULL,'" + dbEscape(self.IDReview) + "', '" + dbEscape(self.Path) + "','" + dbEscape(self.LineStart) + "','" + dbEscape(self.LineEnd) + "','" + dbEscape(self.Version) + "')" cursor.execute(query) db.commit() self.IDFile = cursor.lastrowid; else: #Update information in existing database entry query = "UPDATE ReviewFiles SET IDReview = '" + dbEscape(self.IDReview) + "', Path = '" + dbEscape(self.Path) + + "', LineStart = '" + dbEscape(self.LineStart) + "', LineEnd = '" + dbEscape(self.LineEnd) + "', Version = '" + dbEscape(self.Version) + "' WHERE IDFile = '" + dbEscape(self.IDFile) + "'" cursor.execute(query) db.commit() return self.IDFile
def save(self, db): cursor = db.cursor() #Add information to a new database entry if self.IDComment == "-1": query = "INSERT INTO ReviewComments VALUES(NULL,'" + dbEscape(self.IDFile) + "', '" + dbEscape(self.IDParent) + "','" + dbEscape(self.LineNum) + "','" + dbEscape(self.Author) + "','" + dbEscape(self.Text) + "','" + dbEscape(self.AttachmentPath) + "','" + `self.DateCreate` + "')" cursor.execute(query) db.commit() self.IDComment = cursor.lastrowid; else: #Update information in existing database entry query = "UPDATE ReviewComments SET IDFile = '" + dbEscape(self.IDFile) + "', IDParent = '" + dbEscape(self.IDParent) + "', LineNum = '" + dbEscape(self.LineNum) + "', Author = '" + dbEscape(self.Author) + "', Text = '" + dbEscape(self.Text) + "', AttachmentPath = '" + dbEscape(self.AttachmentPath) + "', DateCreate = '" + `self.DateCreate` + "' WHERE IDComment = '" + dbEscape(self.IDComment) + "'" cursor.execute(query) db.commit() return self.IDComment
def save(self, db): query = "" cursor = db.cursor() #Add information to a new database entry if self.IDReview == "": query = "INSERT INTO CodeReviews VALUES(NULL,'" + dbEscape(self.Author) + "','" + dbEscape(self.Status) + "','" + `self.DateCreate` + "','" + dbEscape(self.Name) + "','" + dbEscape(self.Notes) + "')" cursor.execute(query) db.commit() self.IDReview = cursor.lastrowid; else: #Update information in existing database entry query = "UPDATE CodeReviews SET Author = '" + dbEscape(self.Author) + "', Status = '" + dbEscape(self.Status) + "', DateCreate = '" + `self.DateCreate` + "', Name = '" + dbEscape(self.Name) + "', Notes = '" + dbEscape(self.Notes) + "' WHERE IDReview = '" + dbEscape(self.IDReview) + "'" cursor.execute(query) db.commit() return self.IDReview
def searchCodeReviewsByName(self, name): query = self.createORLoop(dbEscape(name), "Name") if len(queryPart) == 0: query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews" else: query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE " + dbEscape(query) return self.execCodeReviewQuery(query, True)
def searchCodeReviewsByName(self, name): query = self.createORLoop(dbEscape(name), "Name") if len(queryPart) == 0: query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews" else: query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE " + dbEscape( query) return self.execCodeReviewQuery(query, True)
def getVotesByID(self, type, id): query = "SELECT Count(Reviewer) FROM Reviewers WHERE IDReview = '" + dbEscape(id) +"' AND Vote = '" + dbEscape(type) + "'" cursor = self.db.cursor() cursor.execute(query) row = cursor.fetchone() if not row: return 0 return row[0]
def getMyCodeReviews(self, user): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE Author= '" + dbEscape(user) + "' ORDER BY DateCreate" return self.execCodeReviewQuery(query, False)
def getCodeReviews(self, user): query = "SELECT CodeReviews.IDReview, CodeReviews.Author, CodeReviews.Status, CodeReviews.DateCreate, CodeReviews.Name, CodeReviews.Notes FROM CodeReviews, Reviewers WHERE Reviewers.IDReview = CodeReviews.IDReview AND Reviewer = '" + dbEscape(user) + "' ORDER BY CodeReviews.DateCreate" return self.execCodeReviewQuery(query, False)
def getCommentsByFileIDAndLine(self, id, line): query = "SELECT IDComment, IDFile, IDParent, LineNum, Author, Text, AttachmentPath, DateCreate FROM ReviewComments WHERE IDFile = '" + dbEscape(id) + "' AND LineNum = '" + dbEscape(line) + "' ORDER BY DateCreate" return self.execReviewCommentQuery(query, False)
def getCommentDictForFile(self, id): query = "SELECT LineNum, Count(IDComment) FROM ReviewComments WHERE IDFile = '" + dbEscape(id) + "' GROUP BY LineNum" cursor = self.db.cursor() cursor.execute(query) rows = cursor.fetchall() d = {} if not rows: return d for row in rows: d[row[0]] = row[1] return d
def getCommentsByFileIDAndLine(self, id, line): query = "SELECT IDComment, IDFile, IDParent, LineNum, Author, Text, AttachmentPath, DateCreate FROM ReviewComments WHERE IDFile = '" + dbEscape( id) + "' AND LineNum = '" + dbEscape( line) + "' ORDER BY DateCreate" return self.execReviewCommentQuery(query, False)
def getCommentByID(self, id): query = "SELECT IDComment, IDFile, IDParent, LineNum, Author, Text, AttachmentPath, DateCreate FROM ReviewComments WHERE IDComment = '" + dbEscape(id) + "'" return self.execReviewCommentQuery(query, True)
def getCodeReviewsByID(self, id): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE IDReview= '" + dbEscape(id) + "'" return self.execCodeReviewQuery(query, True)
def getReviewers(self, id): query = "SELECT IDReview, Reviewer, Status, Vote FROM Reviewers WHERE IDReview = '" + dbEscape( id) + "'" return self.execReviewerQuery(query, False)
def getReviewerEntry(self, id, name): query = "SELECT IDReview, Reviewer, Status, Vote FROM Reviewers WHERE IDReview = '" + dbEscape(id) + "' AND Reviewer = '" + dbEscape(name) + "'" return self.execReviewerQuery(query, True)
def getReviewFile(self, id): query = "SELECT IDFile, IDReview, Path, LineStart, LineEnd, Version FROM ReviewFiles WHERE IDFile = '" + dbEscape( id) + "'" return self.execReviewFileQuery(query, True)
def save(self, db): cursor = db.cursor() if self.IDFile == "": #Add information to a new database entry query = "INSERT INTO ReviewFiles VALUES(NULL,'" + dbEscape( self.IDReview) + "', '" + dbEscape( self.Path) + "','" + dbEscape( self.LineStart) + "','" + dbEscape( self.LineEnd) + "','" + dbEscape( self.Version) + "')" cursor.execute(query) db.commit() self.IDFile = cursor.lastrowid else: #Update information in existing database entry query = "UPDATE ReviewFiles SET IDReview = '" + dbEscape( self.IDReview) + "', Path = '" + dbEscape( self.Path) + + "', LineStart = '" + dbEscape( self.LineStart) + "', LineEnd = '" + dbEscape( self.LineEnd) + "', Version = '" + dbEscape( self.Version ) + "' WHERE IDFile = '" + dbEscape( self.IDFile) + "'" cursor.execute(query) db.commit() return self.IDFile
def save(self, db): cursor = db.cursor() #Add information to a new database entry if self.IDComment == "-1": query = "INSERT INTO ReviewComments VALUES(NULL,'" + dbEscape( self.IDFile) + "', '" + dbEscape( self.IDParent) + "','" + dbEscape( self.LineNum) + "','" + dbEscape( self.Author) + "','" + dbEscape( self.Text) + "','" + dbEscape( self.AttachmentPath ) + "','" + ` self.DateCreate ` + "')" cursor.execute(query) db.commit() cursor.execute("SELECT last_insert_rowid() FROM ReviewComments") self.IDComment = ` cursor.fetchone()[0] ` else: #Update information in existing database entry query = "UPDATE ReviewComments SET IDFile = '" + dbEscape( self.IDFile ) + "', IDParent = '" + dbEscape( self.IDParent ) + "', LineNum = '" + dbEscape( self.LineNum ) + "', Author = '" + dbEscape( self.Author ) + "', Text = '" + dbEscape( self.Text ) + "', AttachmentPath = '" + dbEscape( self.AttachmentPath ) + "', DateCreate = '" + ` self.DateCreate ` + "' WHERE IDComment = '" + dbEscape( self.IDComment) + "'" cursor.execute(query) db.commit() return self.IDComment
def save(self, db): cursor = db.cursor() if self.IDFile == "": # Add information to a new database entry query = ( "INSERT INTO ReviewFiles VALUES(NULL,'" + dbEscape(self.IDReview) + "', '" + dbEscape(self.Path) + "','" + dbEscape(self.LineStart) + "','" + dbEscape(self.LineEnd) + "','" + dbEscape(self.Version) + "')" ) cursor.execute(query) db.commit() cursor.execute("SELECT last_insert_rowid() FROM ReviewFiles") self.IDFile = ` cursor.fetchone()[0] ` else: # Update information in existing database entry query = ( "UPDATE ReviewFiles SET IDReview = '" + dbEscape(self.IDReview) + "', Path = '" + dbEscape(self.Path) + +"', LineStart = '" + dbEscape(self.LineStart) + "', LineEnd = '" + dbEscape(self.LineEnd) + "', Version = '" + dbEscape(self.Version) + "' WHERE IDFile = '" + dbEscape(self.IDFile) + "'" ) cursor.execute(query) db.commit() return self.IDFile
def getCodeReviewsByStatus(self, status): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE Status= '" + dbEscape(status) + "'ORDER BY DateCreate" return self.execCodeReviewQuery(query, False)
def getCodeReviewsByID(self, id): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE IDReview= '" + dbEscape( id) + "'" return self.execCodeReviewQuery(query, True)
def getCommentByID(self, id): query = "SELECT IDComment, IDFile, IDParent, LineNum, Author, Text, AttachmentPath, DateCreate FROM ReviewComments WHERE IDComment = '" + dbEscape( id) + "'" return self.execReviewCommentQuery(query, True)
def getCommentDictForFile(self, id): query = "SELECT LineNum, Count(IDComment) FROM ReviewComments WHERE IDFile = '" + dbEscape( id) + "' GROUP BY LineNum" cursor = self.db.cursor() cursor.execute(query) rows = cursor.fetchall() d = {} if not rows: return d for row in rows: d[row[0]] = row[1] return d
def getCodeReviewsByStatus(self, status): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE Status= '" + dbEscape( status) + "'ORDER BY DateCreate" return self.execCodeReviewQuery(query, False)
def getMyCodeReviews(self, user): query = "SELECT IDReview, Author, Status, DateCreate, Name, Notes FROM CodeReviews WHERE Author= '" + dbEscape( user) + "' ORDER BY DateCreate" return self.execCodeReviewQuery(query, False)
def getReviewers(self, id): query = "SELECT IDReview, Reviewer, Status, Vote FROM Reviewers WHERE IDReview = '" + dbEscape(id) + "'" return self.execReviewerQuery(query, False)
def getCodeReviews(self, user): query = "SELECT CodeReviews.IDReview, CodeReviews.Author, CodeReviews.Status, CodeReviews.DateCreate, CodeReviews.Name, CodeReviews.Notes FROM CodeReviews, Reviewers WHERE Reviewers.IDReview = CodeReviews.IDReview AND Reviewer = '" + dbEscape( user) + "' ORDER BY CodeReviews.DateCreate" return self.execCodeReviewQuery(query, False)
def getReviewFiles(self, id): query = "SELECT IDFile, IDReview, Path, LineStart, LineEnd, Version FROM ReviewFiles WHERE IDReview = '" + dbEscape(id) + "'" return self.execReviewFileQuery(query, False)
def getReviewerEntry(self, id, name): query = "SELECT IDReview, Reviewer, Status, Vote FROM Reviewers WHERE IDReview = '" + dbEscape( id) + "' AND Reviewer = '" + dbEscape(name) + "'" return self.execReviewerQuery(query, True)