Subversion Repositories DevTools

Rev

Rev 6122 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6122 dpurdie 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
4
'       deployable_state_json.asp
5
'=====================================================
6
%>
7
<%
8
Option explicit
9
' Essential to get UTF through all the hoops. ie: VÄSTTRAFIK (VTK)
10
Response.ContentType = "text/html"
11
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
12
Response.CodePage = 65001
13
Response.CharSet = "UTF-8"
14
%>
15
<!--#include file="common/conf.asp"-->
16
<!--#include file="common/globals.asp"-->
17
<!--#include file="common/qstr.asp"-->
18
<!--#include file="common/common_subs.asp"-->
19
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER SRC="class/classaspJSON.vbs"></SCRIPT> 
20
<%
21
'------------ Variable Definition -------------
22
Dim result : result = -1
23
Dim SqlQry
24
Dim rsQry
25
Dim parRtagId : parRtagId = Request("rtag_id")
26
Dim parShow : parShow = Request("show")
27
 
28
' Init the output JSON class
29
'   Operations can add data
30
'   Default data will be added at the end
31
Dim oJSON :Set oJSON = New aspJSON
32
Dim newitem
33
 
34
'
35
'   Global Filter
36
'
37
Dim showHideFilter
38
If parShow = "true" Then
39
    showHideFilter = searchString & " AND pv.IS_DEPLOYABLE = 'Y'" 
40
End If
41
 
42
' Filter (search )
43
Dim searchString
44
If Request.QueryString("search[value]") <> "" Then
45
    searchString = " AND upper(p.PKG_NAME || '_' || pv.PKG_VERSION ) LIKE upper('%" & Request.QueryString("search[value]") & "%')" 
46
End If
47
 
48
'
49
' Determine the size of the record set
50
'   Gives bad results when searching
51
Dim MaxCount : MaxCount = 0
52
 
53
SqlQry =  "select  count(*) as count " &_ 
54
            " FROM package_versions pv, " &_
55
            "  RELEASE_CONTENT rc, " &_
56
            "  PACKAGES p " &_
57
            " WHERE rc.rtag_id = " & parRtagId &_
58
            "  AND rc.pv_id     = pv.pv_id " &_
59
            "  and p.PKG_ID = pv.pkg_id " &_
60
            searchString &_
61
            showHideFilter
62
 
63
On Error Resume Next
64
objEH.ErrorRedirect = FALSE
65
objEH.TryORA ( OraSession )
66
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
67
objEH.CatchORA ( OraSession )
68
    If ((NOT rsQry.BOF) AND (NOT rsQry.EOF)) Then
69
        MaxCount = rsQry("COUNT")
70
    End If
71
rsQry.Close
72
Set rsQry = Nothing
73
 
74
' Basic Header
75
'   iTotalRecords = total records without any filtering/limits
76
'   iTotalDisplayRecords = filtered result count
77
 
78
oJSON.data("draw") = CLng(Request.QueryString("draw"))
79
oJSON.data("recordsTotal") = MaxCount
80
oJSON.data("recordsFiltered") = MaxCount
81
 
82
Dim vName
83
for each vName in Request.QueryString
84
    oJSON.data("sReq_" & vName) = Request.QueryString(vName)
85
next
86
 
87
' Extract selected range
88
result = 0
89
dim firstRow,lastRow
90
firstRow = CLng(Request.QueryString("start"))
91
lastRow = firstRow + CLng(Request.QueryString("length"))
92
 
93
' Define the data items to extract from the database
94
' An array of items to extract
95
'
96
Dim dataCols: dataCols = Array ( _
97
        "pv.pv_id", _
98
        "pv.pkg_id", _
99
        "p.PKG_NAME", _
100
        "pv.PKG_VERSION", _
101
        "pv.PV_DESCRIPTION", _
102
        "pv.v_ext", _
103
        "pv.IS_DEPLOYABLE", _
104
        "pv.COMMENTS" )
105
 
106
'   Define array of colums to sort by
107
'       Must match user sort column request
108
Dim sortCols: sortCols = Array ( _
109
        "pv.pv_id",_
110
        "UPPER(p.PKG_NAME)",_
111
        "UPPER(pv.PKG_VERSION)",_
112
        "UPPER(pv.v_ext)",_
113
        "UPPER(pv.PV_DESCRIPTION)",_
114
        "UPPER(pv.IS_DEPLOYABLE)" )
115
 
116
' Dim determine sorting options
117
'On Error goto 0
118
'Response.Write "<pre>"
119
 
120
' Dim determine sorting options
121
'   Secondary sort by package name Entry(1)
122
Dim sortString
123
Dim sortColumn : sortColumn = CInt(Request.QueryString("order[0][column]"))
124
Dim sortDir    : sortDir = Request.QueryString("order[0][dir]")
125
 
126
If sortColumn <> "" Then
127
    sortString = " ORDER BY " & sortCols(sortColumn) & " " & sortDir
128
    If sortColumn <> "1" Then
129
        sortString = sortString & ", " & sortCols(CInt(1)) & " " & sortDir
130
    End If
131
Else
132
    sortString = " ORDER BY " & sortCols(CInt(1)) & " asc"
133
End If
134
 
135
' Create a list of cols that we need. Avoids ambiguity in selections
136
Dim x,colList,colListJoin
137
For x = Lbound(dataCols) to Ubound(dataCols)
138
    colList = colList & colListJoin & dataCols(x)
139
    colListJoin = ","
140
Next
141
 
142
Dim BasicSql
143
BasicSql =  "select " & colList &_ 
144
            " FROM package_versions pv, " &_
145
            "  RELEASE_CONTENT rc, " &_
146
            "  PACKAGES p " &_
147
            " WHERE rc.rtag_id = " & parRtagId &_
148
            "  AND rc.pv_id     = pv.pv_id " &_
149
            "  and p.PKG_ID = pv.pkg_id " &_
150
            searchString &_
151
            showHideFilter &_
152
            sortString
153
 
154
SqlQry = "select * from ( "&_
155
            "select a.*, ROWNUM rnum from (" & BasicSql &_
156
                ") a where ROWNUM <= " & lastRow &_
157
            ") where rnum >= " & firstRow
158
 
159
' Assist in debug
160
oJSON.data("BasicSql") = BasicSql
161
oJSON.data("SqlQry") = SqlQry
162
 
163
' Perform the database query
164
Set oJSON.data("data") = oJSON.Collection()
165
On Error Resume Next
166
objEH.ErrorRedirect = FALSE
167
objEH.TryORA ( OraSession )
168
Set rsQry = OraDatabase.DbCreateDynaset( SqlQry, ORADYN_DEFAULT )
169
objEH.CatchORA ( OraSession )
170
' Process each row and return required fields to the user
171
If objEH.Finally Then
172
   While (NOT rsQry.BOF) AND (NOT rsQry.EOF)
173
        Set newitem = oJSON.AddToCollection(oJSON.data("data"))
174
 
175
        ' Attempt to speed up access to the data
176
        '    Extract all fields for the row
177
        '    Access fields by index
178
        Dim fields
179
        Set fields = rsQry.Fields
180
 
181
        Dim pv_id        : pv_id = fields(0)
182
        Dim pkg_id       : pkg_id = fields(1)
183
        Dim pkg_name     : pkg_name = fields(2)
184
        Dim pkg_version  : pkg_version = fields(3)
185
        Dim description  : description = Server.HTMLEncode(fields(4))
186
        Dim v_ext        : v_ext = fields(5)
187
        Dim state        : state = fields(6)
7395 dpurdie 188
        Dim comments     : comments = CleanUpJson(Server.HTMLEncode(fields(7)))
6122 dpurdie 189
 
190
        Set fields = nothing
191
 
192
        newitem(0) = pv_id
193
        newitem(1) = "<a href=view_by_version.asp?pkg_id=" & pkg_id & "&fpkgversion=*" & v_ext & " title=""" & description & """>" & pkg_name & "</a>"
194
        newitem(2) = "<a href='fixed_issues.asp?pv_id=" & pv_id & "&rtag_id=" & parRtagId &"' title=""" & comments & """>" & pkg_version & "</a>"
195
        newitem(3) = v_ext
196
        newitem(4) = description
197
        newitem(5) = state
198
 
199
        rsQry.MoveNext
200
   Wend
201
End IF
202
 
203
rsQry.Close
204
Set rsQry = Nothing
205
 
206
'
207
' SQL error detection and reporting
208
If objEH.LastOraFailed Then
209
    oJSON.data("error") = 1
210
 
211
    oJSON.data("emsgSummary") = objEH.MessageSummary
212
    oJSON.data("emsgDetails") = objEH.MessageDetails
213
    oJSON.data("SqlQry") = SqlQry
214
End If
215
 
216
'Return the object
217
Response.Write oJSON.JSONoutput()
218
Set oJSON = Nothing
219
Call Destroy_All_Objects
220
%>