From ea46f42ee640928b92947bfb204c41a482d80937 Mon Sep 17 00:00:00 2001
From: root
Date: Tue, 8 May 2012 18:39:56 -0500
Subject: Add all the source codes into the github.
---
web/webqtl/schema/ShowCommentPage.py | 123 +++++++++++++++++++++
web/webqtl/schema/ShowSchemaPage.py | 194 +++++++++++++++++++++++++++++++++
web/webqtl/schema/UpdateCommentPage.py | 101 +++++++++++++++++
web/webqtl/schema/__init__.py | 0
4 files changed, 418 insertions(+)
create mode 100755 web/webqtl/schema/ShowCommentPage.py
create mode 100755 web/webqtl/schema/ShowSchemaPage.py
create mode 100755 web/webqtl/schema/UpdateCommentPage.py
create mode 100755 web/webqtl/schema/__init__.py
(limited to 'web/webqtl/schema')
diff --git a/web/webqtl/schema/ShowCommentPage.py b/web/webqtl/schema/ShowCommentPage.py
new file mode 100755
index 00000000..449fd56a
--- /dev/null
+++ b/web/webqtl/schema/ShowCommentPage.py
@@ -0,0 +1,123 @@
+# Copyright (C) University of Tennessee Health Science Center, Memphis, TN.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# This program is available from Source Forge: at GeneNetwork Project
+# (sourceforge.net/projects/genenetwork/).
+#
+# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
+# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
+#
+#
+#
+# This module is used by GeneNetwork project (www.genenetwork.org)
+#
+# Created by GeneNetwork Core Team 2010/08/10
+#
+# Last updated by GeneNetwork Core Team 2010/10/20
+
+import sys
+
+from htmlgen import HTMLgen2 as HT
+
+from base.templatePage import templatePage
+from base import webqtlConfig
+
+
+
+class ShowCommentPage(templatePage):
+ def __init__(self,fd):
+ sys.stderr = sys.stdout
+
+ templatePage.__init__(self, fd)
+
+ if not self.openMysql():
+ #{
+ print 'Content-type: text/html\n'
+ print 'Can not update the comment of %s' %(TableName)
+ return
+ #}
+
+ Cursor_Comment = self.cursor
+ TableName = fd.formdata.getfirst('TableName')
+
+ SqlCmd = 'select Comment from TableComments where TableName=\'%s\'' %(TableName)
+ Cursor_Comment.execute(SqlCmd)
+ Comment = Cursor_Comment.fetchall()
+ if Comment:
+ Comment = Comment[0][0]
+ if str(Comment)=='None':
+ Comment=''
+ else:
+ Comment = ''
+
+ ##########setup HtmlForm Comment##########
+ HtmlInputHidden_TableName = HT.Input(type='hidden', name='TableName', value=TableName)
+ HtmlInputHidden_ActionID = HT.Input(type='hidden', name='ActionID', value='UpdateComment')
+ HtmlTextarea_Comment = HT.Textarea(name='Comment', text=Comment, rows=8, cols=100)
+
+ HtmlForm_Comment = HT.Form(cgi=webqtlConfig.CGIDIR+'main.py?FormID=schemaUpdateComment')
+ HtmlForm_Comment.append('%s
' %(TableName)) #show table's name
+ HtmlForm_Comment.append('Comment:
') #show table's comment
+ HtmlForm_Comment.append(HtmlTextarea_Comment)
+ HtmlForm_Comment.append('
')
+ HtmlForm_Comment.append(HtmlInputHidden_TableName)
+ HtmlForm_Comment.append(HtmlInputHidden_ActionID)
+
+ ###########################
+ #update fields' annotation#
+ ###########################
+ HtmlForm_Comment.append('
')
+
+ try:
+ #{
+ HtmlTR_Annotation = []
+ Cursor_Comment.execute('desc %s' %(TableName))
+ TableDesc = Cursor_Comment.fetchall()
+ for i in range(0, len(TableDesc)):
+ #{
+ TableField = TableName+'.'+str(TableDesc[i][0])
+ TableFieldForeignKey = TableField+'ForeignKey'
+ TableFieldAnnotation = TableField+'Annotation'
+ HtmlText_ForeignKey = HT.Input(type='text', name=TableFieldForeignKey, size=20)
+ HtmlText_Annotation = HT.Input(type='text', name=TableFieldAnnotation, size=80)
+
+
+ Cursor_Comment.execute('select Annotation, Foreign_Key from TableFieldAnnotation where TableField=%s', (TableField))
+ Annotation = Cursor_Comment.fetchone()
+ if Annotation:
+ #{
+ if str(Annotation[1]) != 'None':
+ HtmlText_ForeignKey.value=Annotation[1]
+ if str(Annotation[0]) != 'None':
+ HtmlText_Annotation.value=Annotation[0].replace('"', '"')
+ #}
+ HtmlTD_Annotation = []
+ HtmlTD_Annotation.append(TableField)
+ HtmlTD_Annotation.append(HtmlText_ForeignKey)
+ HtmlTD_Annotation.append(HtmlText_Annotation)
+
+ HtmlTR_Annotation.append(HtmlTD_Annotation)
+ #}
+
+ HtmlTable_Annotation= HT.Table(border=0, width='0%', heading=['Field', 'Foreign_Key', 'Annotation'], body = HtmlTR_Annotation)
+ HtmlForm_Comment.append(HtmlTable_Annotation)
+ #}
+ except:
+ pass
+
+ HtmlForm_Comment.submit.value='submit'
+ HtmlForm_Comment.reset = HT.Input(type='reset', name='reset', value='reset')
+ ##########end of HtmlForm##########
+
+ self.dict['body'] = HtmlForm_Comment
+
+
diff --git a/web/webqtl/schema/ShowSchemaPage.py b/web/webqtl/schema/ShowSchemaPage.py
new file mode 100755
index 00000000..e9ced5a1
--- /dev/null
+++ b/web/webqtl/schema/ShowSchemaPage.py
@@ -0,0 +1,194 @@
+# Copyright (C) University of Tennessee Health Science Center, Memphis, TN.
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Affero General Public License
+# as published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the GNU Affero General Public License for more details.
+#
+# This program is available from Source Forge: at GeneNetwork Project
+# (sourceforge.net/projects/genenetwork/).
+#
+# Contact Drs. Robert W. Williams and Xiaodong Zhou (2010)
+# at rwilliams@uthsc.edu and xzhou15@uthsc.edu
+#
+#
+#
+# This module is used by GeneNetwork project (www.genenetwork.org)
+#
+# Created by GeneNetwork Core Team 2010/08/10
+#
+# Last updated by GeneNetwork Core Team 2010/10/20
+
+import sys
+
+from htmlgen import HTMLgen2 as HT
+
+from base.templatePage import templatePage
+from base import webqtlConfig
+from utility import webqtlUtil
+
+
+
+###################################################
+#Description: show the schema of webqtl's database#
+#Author: Hongqiang Li #
+#Version: 1.0 #
+###################################################
+
+class ShowSchemaPage(templatePage):
+ def __init__(self,fd):
+ cookies = fd.cookies
+ sys.stderr = sys.stdout
+ templatePage.__init__(self, fd)
+ body = HT.SimpleDocument()
+
+ ###############################################################################
+ #get user's privilege from cookie, if the user doesn't have enough privilege, #
+ #he won't see the update comment icon #
+ ###############################################################################
+ ShowUpdateIcon = False
+
+ if not self.openMysql():
+ return
+
+ Cursor_WebQtl = Cursor_Comment = self.cursor
+
+ if webqtlConfig.USERDICT[self.privilege] >= webqtlConfig.USERDICT['user']:
+ ShowUpdateIcon = True
+
+ ##################
+ #show description#
+ ##################
+ body.append('
')
+ body.append('