Subversion Repositories DevTools

Rev

Rev 5506 | Rev 5895 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
119 ghuddy 1
<%@LANGUAGE="VBSCRIPT"%>
2
<%
3
'=====================================================
5893 dpurdie 4
'               UPDATE dependencies
5
'               _update_dependencies.asp
119 ghuddy 6
'               --- PROCESS FORM ---
7
'=====================================================
8
%>
9
<%
10
Option explicit
11
' Good idea to set when using redirect
129 ghuddy 12
Response.Expires = 0   ' always load the page, dont store
119 ghuddy 13
%>
14
 
15
<!--#include file="common/conf.asp"-->
16
<!--#include file="common/globals.asp"-->
17
<!--#include file="common/formating.asp"-->
18
<!--#include file="common/qstr.asp"-->
19
<!--#include file="common/common_subs.asp"-->
20
<!--#include file="common/common_dbedit.asp"-->
21
<%
22
' Set rfile parameter. This is a return page after Login
23
Call objPMod.StoreParameter ( "rfile", "dependencies.asp" )
24
'------------ ACCESS CONTROL ------------------
25
%>
26
<!--#include file="_access_control_login.asp"-->
27
<!--#include file="_access_control_general.asp"-->
28
<!--#include file="_access_control_project.asp"-->
29
<%
30
'------------ Variable Definition -------------
31
Dim depArray()
32
Dim array_is_empty
33
'------------ Constants Declaration -----------
34
Const enumlocal_DONOT_DELETE_OLD_DEPENDENCIES = 0
35
Const enumlocal_DELETE_OLD_DEPENDENCIES = 1
36
Const COL_pkg_name = 0
37
Const COL_pkg_version = 1
38
Const COL_build_type = 2
39
'------------ Variable Init -------------------
40
'----------------------------------------------
41
%>
42
<%
5893 dpurdie 43
'
44
'   Populate from a form
45
'       Assumes that items are seqentially numbered starting at 1
46
Sub Populate_depArray_from_Import ( ARRdep, BBarray_is_empty )
47
   Dim recCnt, pkg_name, pkg_version, build_type
121 hknight 48
 
161 iaugusti 49
   recCnt=0
5893 dpurdie 50
   BBarray_is_empty = true
51
   Do While TRUE
52
       pkg_name = Request("btName" & recCnt + 1)
53
       pkg_version = Request("pkgn" & recCnt + 1)
54
       build_type = Request("bt" & recCnt + 1)
55
 
56
          ' Proceed only if:
57
          '    pkg name is not empty,
58
          '    pkg version is not empty,
59
          If ( pkg_name <> "" )  AND  ( pkg_version <> "" ) Then
60
             ReDim Preserve ARRdep( 2, recCnt )
61
             ARRdep( COL_pkg_name, recCnt ) = pkg_name
62
             ARRdep( COL_pkg_version, recCnt ) = pkg_version
63
             ARRdep( COL_build_type, recCnt ) = build_type
64
             recCnt = recCnt + 1
65
             BBarray_is_empty = FALSE
129 ghuddy 66
         Else
5893 dpurdie 67
            Exit Do
129 ghuddy 68
         End If
5893 dpurdie 69
   Loop
119 ghuddy 70
End Sub
71
 
121 hknight 72
' This function is called when update_type is "add_custom". This is only the case when adding dependencies
73
' The list given via the actual parameter pkg_list is in fact a list of pv_id's supplied from the form_search_result_pkgs.asp
74
' and form_add_pkg_versions.asp files. In the past, it only ever used to be a list of package IDs, but this has now been
75
' changed so that users can only add package versions from the relevant release as dependencies to a packge also in that
76
' release, and to do this, the list has to hold pv_id's instead of pkg_id's, to cater for situations where a release
77
' contains 2 instances of a package, each one having different extensions (eg .mas, .sea).
78
Sub Populate_depArray_from_ADD_Custom ( NNpv_id_list, ARRdep, BBarray_is_empty )
129 ghuddy 79
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
80
   Dim rsTemp, Query_String, PkgBaseView
121 hknight 81
 
129 ghuddy 82
   PkgBaseView = Get_Pkg_Base_View_ID ( Request("pv_id"), Request("rtag_id") )
121 hknight 83
 
129 ghuddy 84
   Query_String = _
121 hknight 85
   " SELECT pkgs.pkg_id, pkgs.pkg_name, pv.pv_id, pv.pkg_version"&_
86
   "  FROM packages pkgs, package_versions pv"&_
87
   " WHERE pv.pv_id IN ("& NNpv_id_list &")"&_
88
   "   AND pv.pkg_id = pkgs.pkg_id"
129 ghuddy 89
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 90
 
129 ghuddy 91
   recCnt = 0
92
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
93
      ReDim Preserve ARRdep( 2, recCnt )
94
      ARRdep( COL_pkg_name, recCnt ) = rsTemp("pkg_name")
121 hknight 95
      ARRdep( COL_pkg_version, recCnt ) = rsTemp("pkg_version")
96
 
129 ghuddy 97
      '// Dependencies comming from custom dependency add are set to LinkPkgArchive by default, unless it is a product
98
      If PkgBaseView = enumBASE_VIEW_PRODUCTS Then
99
         ARRdep( COL_build_type, recCnt ) = enum_BUILD_PKG_ARCHIVE
100
      Else
101
         ARRdep( COL_build_type, recCnt ) = enum_LINK_PKG_ARCHIVE
102
      End If
121 hknight 103
 
129 ghuddy 104
      recCnt = recCnt + 1
105
      BBarray_is_empty = FALSE
106
      rsTemp.MoveNext
107
   WEnd
121 hknight 108
 
129 ghuddy 109
   rsTemp.Close
110
   Set rsTemp = nothing
119 ghuddy 111
End Sub
112
 
3959 dpurdie 113
// The form passed to us may only have information for packages that need to change
114
// The enumlocal_DONOT_DELETE_OLD_DEPENDENCIES does not appear to work
115
//  Must provide a full set of dependencies with either a new version or the existing version
116
//
119 ghuddy 117
Sub Populate_depArray_from_EDIT_Custom ( NNpv_id, ARRdep, BBarray_is_empty, sDependBlock )
129 ghuddy 118
   Dim depList, lastItem, i, recCnt, pkg_name, pkg_version, V_EXT
119
   Dim rsTemp, rsCurrent, Query_String
121 hknight 120
 
129 ghuddy 121
   Query_String = _
122
   " SELECT dpkg.pkg_name, dpv.pkg_version, dpv.pv_id"&_
123
   "  FROM package_dependencies dep,"&_
124
   "       package_versions dpv,"&_
125
   "       packages dpkg"&_
126
   " WHERE dep.dpv_id = dpv.pv_id"&_
127
   "   AND dpv.pkg_id = dpkg.pkg_id"&_
128
   "   AND dep.pv_id = "& NNpv_id
121 hknight 129
 
129 ghuddy 130
   Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
121 hknight 131
 
129 ghuddy 132
   recCnt = 0
133
   While ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF))
3959 dpurdie 134
      Dim pvid, pkgver, newver
135
      pvid = rsTemp("pv_id")
136
      pkgver = Request( "pkgn" & pvid )
137
 
138
      If pkgver <> "" Then
139
        newver = pkgver
140
      else
141
        newver = rsTemp("pkg_version")
142
      End if
143
 
129 ghuddy 144
      ReDim Preserve ARRdep( 2, recCnt )
145
      ARRdep( COL_pkg_name, recCnt )    = rsTemp("pkg_name")
3959 dpurdie 146
      ARRdep( COL_pkg_version, recCnt ) = newver
147
      ARRdep( COL_build_type, recCnt )  = Request( "bt"& pvid )
119 ghuddy 148
 
3959 dpurdie 149
      If not rsTemp("pkg_version") =  newver Then
150
         sDependBlock = rsTemp("pkg_name") & " " & newver
129 ghuddy 151
      End If
121 hknight 152
 
129 ghuddy 153
      recCnt = recCnt + 1
154
      BBarray_is_empty = FALSE
3959 dpurdie 155
 
129 ghuddy 156
      rsTemp.MoveNext
157
   WEnd
121 hknight 158
 
129 ghuddy 159
   rsTemp.Close
160
   Set rsTemp = nothing
5893 dpurdie 161
 
119 ghuddy 162
End Sub
163
 
164
Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )
129 ghuddy 165
   Dim i, OraParameter, sComments
121 hknight 166
 
129 ghuddy 167
   OraDatabase.Parameters.Add "PV_ID",            NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
168
   OraDatabase.Parameters.Add "PKG_NAME",         "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
169
   OraDatabase.Parameters.Add "PKG_VERSION",      "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
170
   OraDatabase.Parameters.Add "BUILD_TYPE",       "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
171
   OraDatabase.Parameters.Add "USER_ID",          NNuser_id,               ORAPARM_INPUT, ORATYPE_NUMBER
172
   OraDatabase.Parameters.Add "DELETE_PV_ID",     NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER
173
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type,            ORAPARM_INPUT, ORATYPE_VARCHAR2
121 hknight 174
 
129 ghuddy 175
   Set OraParameter = OraDatabase.Parameters
121 hknight 176
 
129 ghuddy 177
   For i = 0 To UBound( ARRdep, 2 )
178
      If not i = 0 Then
179
         sComments = sComments & ", "
180
      End If
181
      sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )
121 hknight 182
 
129 ghuddy 183
      OraParameter("PKG_NAME").Value    = ARRdep( COL_pkg_name, i )
184
      OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )
185
      OraParameter("BUILD_TYPE").Value  = ARRdep( COL_build_type, i )
121 hknight 186
 
129 ghuddy 187
      OraDatabase.ExecuteSQL "BEGIN  Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID );  END;"
121 hknight 188
 
129 ghuddy 189
   Next
121 hknight 190
 
129 ghuddy 191
   Set OraParameter = Nothing
121 hknight 192
 
129 ghuddy 193
   If sAction_type = "depend_add" Then
194
      OraDatabase.Parameters.Add "COMMENTS",    sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2
195
   Else
196
      If Len(sDependBlock) <= 4000 Then
197
         OraDatabase.Parameters.Add "COMMENTS",    sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2
198
      Else
199
         OraDatabase.Parameters.Add "COMMENTS",    "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2
200
      End If
201
   End If
119 ghuddy 202
 
129 ghuddy 203
   OraDatabase.ExecuteSQL _
204
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
119 ghuddy 205
 
121 hknight 206
 
207
 
129 ghuddy 208
   OraDatabase.Parameters.Remove "PV_ID"
209
   OraDatabase.Parameters.Remove "PKG_NAME"
210
   OraDatabase.Parameters.Remove "PKG_VERSION"
211
   OraDatabase.Parameters.Remove "BUILD_TYPE"
212
   OraDatabase.Parameters.Remove "USER_ID"
213
   OraDatabase.Parameters.Remove "DELETE_PV_ID"
214
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
215
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 216
End Sub
217
 
218
 
219
Sub Remove_Old_Dependencies ( SSpv_id )
129 ghuddy 220
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 221
 
129 ghuddy 222
   OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"
121 hknight 223
 
129 ghuddy 224
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 225
End Sub
226
 
227
 
228
Sub Update_Mod_Details ( SSpv_id )
129 ghuddy 229
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
230
   OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),      ORAPARM_INPUT, ORATYPE_NUMBER
231
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 232
 
129 ghuddy 233
   OraDatabase.ExecuteSQL _
234
      " UPDATE package_versions "&_
235
       " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_
236
       " WHERE pv_id = :PV_ID"
121 hknight 237
 
129 ghuddy 238
   If Request("rtag_id") <> "" Then
239
      ' Package in release view
240
      OraDatabase.ExecuteSQL _
241
        "BEGIN "&_
242
      " Touch_Release ( :RTAG_ID ); "&_
243
      "END; "
121 hknight 244
 
129 ghuddy 245
   Else
246
      ' Package view
247
      OraDatabase.ExecuteSQL _
248
        "BEGIN "&_
249
      " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_
250
      "END; "
121 hknight 251
 
129 ghuddy 252
   End If
121 hknight 253
 
129 ghuddy 254
   OraDatabase.Parameters.Remove "PV_ID"
255
   OraDatabase.Parameters.Remove "RTAG_ID"
256
   OraDatabase.Parameters.Remove "USER_ID"
119 ghuddy 257
End Sub
258
 
259
%>
260
<%
261
'-----------------------  MAIN LINE  ---------------------------
3959 dpurdie 262
'Response.Write "<pre>------------<br>"
263
'Dim Item
264
'For Each Item In Request.Form
265
'    Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "<br>"
266
'Next
267
'Response.Write "------------<br>"
119 ghuddy 268
 
269
Dim sDependBlock
270
 
271
'--- Process submition ---
272
If (QStrPar("pv_id") <> "")  Then
1376 dpurdie 273
   ' All mandatory parameters FOUND
121 hknight 274
 
129 ghuddy 275
   Err.Clear
276
   On Error Resume Next
277
   OraSession.BeginTrans
278
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
279
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
280
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
281
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 282
 
129 ghuddy 283
   array_is_empty = TRUE
284
   If Request("update_type") = "add_custom" Then
285
      '---- ADD CUSTOM dependency ----
121 hknight 286
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
287
      ' (see form_search_pkgs.asp and form_search_result_pkgs.asp) returns a list called "pkg_list", it actually contains a pv_id list in these
288
      ' special cases.
129 ghuddy 289
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 290
 
129 ghuddy 291
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
292
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
293
      End If
119 ghuddy 294
 
121 hknight 295
 
129 ghuddy 296
   ElseIf Request("update_type") = "edit_custom" Then
297
      '---- EDIT CUSTOM dependency ----
298
      Call Populate_depArray_from_EDIT_Custom ( Request("pv_id"), depArray, array_is_empty, sDependBlock )
299
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 300
 
129 ghuddy 301
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
302
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_update", sDependBlock )
303
      End If
119 ghuddy 304
 
121 hknight 305
 
5893 dpurdie 306
   ElseIf Request("update_type") = "edit_import" Then
307
      '-- JATS,ANT dependency import after being edited
308
      Call Populate_depArray_from_Import ( depArray, array_is_empty )
129 ghuddy 309
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 310
 
129 ghuddy 311
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
312
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
313
      End If
5893 dpurdie 314
   Else
315
      '---- Unknown input type
316
        Response.write "Internal error. Unknown update_type!" & "<br>" 'TODO
317
        Err.number = 1
129 ghuddy 318
   End If
121 hknight 319
 
320
 
129 ghuddy 321
   If Err.number = 0 Then
322
      Call Update_Mod_Details ( Request("pv_id") )
323
   End If
121 hknight 324
 
325
 
129 ghuddy 326
   If Err.number <> 0 Then
327
      OraSession.RollBack
328
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
329
   Else
330
      OraSession.CommitTrans
331
   End If
121 hknight 332
 
129 ghuddy 333
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 334
Else
1376 dpurdie 335
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
4955 dpurdie 336
   Response.write QSTR_FullQuery
119 ghuddy 337
End If
338
%>
339
 
340
<!-- DESTRUCTOR ------->
121 hknight 341
<!--#include file="common/destructor.asp"-->