Subversion Repositories DevTools

Rev

Rev 5895 | 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
5895 dpurdie 45
'       Assumes that items are seqentially numbered starting at 0
5893 dpurdie 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
5895 dpurdie 52
       pkg_name = Request("btName" & recCnt)
53
       pkg_version = Request("pkgn" & recCnt)
54
       build_type = Request("bt" & recCnt)
5893 dpurdie 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
 
113
Sub Update_Package_Dependencies ( ARRdep, NNpv_id, NNuser_id, NNdelete_old_dependency, sAction_type, sDependBlock )
129 ghuddy 114
   Dim i, OraParameter, sComments
121 hknight 115
 
129 ghuddy 116
   OraDatabase.Parameters.Add "PV_ID",            NNpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
117
   OraDatabase.Parameters.Add "PKG_NAME",         "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
118
   OraDatabase.Parameters.Add "PKG_VERSION",      "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
119
   OraDatabase.Parameters.Add "BUILD_TYPE",       "",                      ORAPARM_INPUT, ORATYPE_VARCHAR2
120
   OraDatabase.Parameters.Add "USER_ID",          NNuser_id,               ORAPARM_INPUT, ORATYPE_NUMBER
121
   OraDatabase.Parameters.Add "DELETE_PV_ID",     NNdelete_old_dependency, ORAPARM_INPUT, ORATYPE_NUMBER
122
   OraDatabase.Parameters.Add "ACTION_TYPE_NAME", sAction_type,            ORAPARM_INPUT, ORATYPE_VARCHAR2
121 hknight 123
 
129 ghuddy 124
   Set OraParameter = OraDatabase.Parameters
121 hknight 125
 
129 ghuddy 126
   For i = 0 To UBound( ARRdep, 2 )
127
      If not i = 0 Then
128
         sComments = sComments & ", "
129
      End If
130
      sComments = sComments & depArray(COL_pkg_name, i) & " " & ARRdep( COL_pkg_version, i )
121 hknight 131
 
129 ghuddy 132
      OraParameter("PKG_NAME").Value    = ARRdep( COL_pkg_name, i )
133
      OraParameter("PKG_VERSION").Value = ARRdep( COL_pkg_version, i )
134
      OraParameter("BUILD_TYPE").Value  = ARRdep( COL_build_type, i )
121 hknight 135
 
129 ghuddy 136
      OraDatabase.ExecuteSQL "BEGIN  Update_Package_Dependency ( :PV_ID, :PKG_NAME, :PKG_VERSION, :BUILD_TYPE, :USER_ID, :DELETE_PV_ID );  END;"
121 hknight 137
 
129 ghuddy 138
   Next
121 hknight 139
 
129 ghuddy 140
   Set OraParameter = Nothing
121 hknight 141
 
129 ghuddy 142
   If sAction_type = "depend_add" Then
143
      OraDatabase.Parameters.Add "COMMENTS",    sComments, ORAPARM_INPUT, ORATYPE_VARCHAR2
144
   Else
145
      If Len(sDependBlock) <= 4000 Then
146
         OraDatabase.Parameters.Add "COMMENTS",    sDependBlock, ORAPARM_INPUT, ORATYPE_VARCHAR2
147
      Else
148
         OraDatabase.Parameters.Add "COMMENTS",    "Description too long to be inserted!", ORAPARM_INPUT, ORATYPE_VARCHAR2
149
      End If
150
   End If
119 ghuddy 151
 
129 ghuddy 152
   OraDatabase.ExecuteSQL _
153
   "BEGIN  Log_Action ( :PV_ID, :ACTION_TYPE_NAME, :USER_ID, :COMMENTS );  END;"
119 ghuddy 154
 
129 ghuddy 155
   OraDatabase.Parameters.Remove "PV_ID"
156
   OraDatabase.Parameters.Remove "PKG_NAME"
157
   OraDatabase.Parameters.Remove "PKG_VERSION"
158
   OraDatabase.Parameters.Remove "BUILD_TYPE"
159
   OraDatabase.Parameters.Remove "USER_ID"
160
   OraDatabase.Parameters.Remove "DELETE_PV_ID"
161
   OraDatabase.Parameters.Remove "ACTION_TYPE_NAME"
162
   OraDatabase.Parameters.Remove "COMMENTS"
119 ghuddy 163
End Sub
164
 
165
 
166
Sub Remove_Old_Dependencies ( SSpv_id )
129 ghuddy 167
   OraDatabase.Parameters.Add "PV_ID", SSpv_id,    ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 168
 
129 ghuddy 169
   OraDatabase.ExecuteSQL "DELETE FROM package_dependencies WHERE pv_id = :PV_ID"
121 hknight 170
 
129 ghuddy 171
   OraDatabase.Parameters.Remove "PV_ID"
119 ghuddy 172
End Sub
173
 
174
 
175
Sub Update_Mod_Details ( SSpv_id )
129 ghuddy 176
   OraDatabase.Parameters.Add "PV_ID",   SSpv_id,                 ORAPARM_INPUT, ORATYPE_NUMBER
177
   OraDatabase.Parameters.Add "RTAG_ID", Request("rtag_id"),      ORAPARM_INPUT, ORATYPE_NUMBER
178
   OraDatabase.Parameters.Add "USER_ID", objAccessControl.UserId, ORAPARM_INPUT, ORATYPE_NUMBER
121 hknight 179
 
129 ghuddy 180
   OraDatabase.ExecuteSQL _
181
      " UPDATE package_versions "&_
182
       " SET modified_stamp = "& ORA_SYSDATETIME &", modifier_id = :USER_ID"&_
183
       " WHERE pv_id = :PV_ID"
121 hknight 184
 
129 ghuddy 185
   If Request("rtag_id") <> "" Then
186
      ' Package in release view
187
      OraDatabase.ExecuteSQL _
188
        "BEGIN "&_
189
      " Touch_Release ( :RTAG_ID ); "&_
190
      "END; "
121 hknight 191
 
129 ghuddy 192
   Else
193
      ' Package view
194
      OraDatabase.ExecuteSQL _
195
        "BEGIN "&_
196
      " PK_RELEASE.RUN_POST_ACTIONS_BULK ( :PV_ID ); "&_
197
      "END; "
121 hknight 198
 
129 ghuddy 199
   End If
121 hknight 200
 
129 ghuddy 201
   OraDatabase.Parameters.Remove "PV_ID"
202
   OraDatabase.Parameters.Remove "RTAG_ID"
203
   OraDatabase.Parameters.Remove "USER_ID"
119 ghuddy 204
End Sub
205
 
206
%>
207
<%
208
'-----------------------  MAIN LINE  ---------------------------
3959 dpurdie 209
'Response.Write "<pre>------------<br>"
210
'Dim Item
211
'For Each Item In Request.Form
212
'    Response.Write "User Data: " &Item & ": " & Request.Form(Item) & "<br>"
213
'Next
214
'Response.Write "------------<br>"
119 ghuddy 215
 
216
Dim sDependBlock
217
 
218
'--- Process submition ---
219
If (QStrPar("pv_id") <> "")  Then
1376 dpurdie 220
   ' All mandatory parameters FOUND
121 hknight 221
 
129 ghuddy 222
   Err.Clear
223
   On Error Resume Next
224
   OraSession.BeginTrans
225
   ' The called subroutines beneath here do not use "on error resume next", but this calling code does, so if any error
226
   ' occurs in the called functions, control will resume within this code somewhere. On the assumption that an error might
227
   ' be the result of some problem in the database, further database commands are not performed, achieved by making them
228
   ' conditional upon Err.Number being zero. Ultimately, this should result in a rollback
121 hknight 229
 
129 ghuddy 230
   array_is_empty = TRUE
231
   If Request("update_type") = "add_custom" Then
232
      '---- ADD CUSTOM dependency ----
121 hknight 233
      ' NOTE - this happens when user clicks the Add action button on the dependencies/runtime tabs. Although the underlying search operation
234
      ' (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
235
      ' special cases.
129 ghuddy 236
      Call Populate_depArray_from_ADD_Custom ( Request("pkg_list"), depArray, array_is_empty )
121 hknight 237
 
129 ghuddy 238
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
239
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DELETE_OLD_DEPENDENCIES, "depend_add", null )
240
      End If
119 ghuddy 241
 
5893 dpurdie 242
   ElseIf Request("update_type") = "edit_import" Then
243
      '-- JATS,ANT dependency import after being edited
244
      Call Populate_depArray_from_Import ( depArray, array_is_empty )
129 ghuddy 245
      Call Remove_Old_Dependencies ( Request("pv_id") )
121 hknight 246
 
129 ghuddy 247
      If ((NOT array_is_empty) AND (Err.number = 0)) Then
248
         Call Update_Package_Dependencies ( depArray, Request("pv_id"), objAccessControl.UserId, enumlocal_DONOT_DELETE_OLD_DEPENDENCIES, "depend_import", Request("FRdeps") )
249
      End If
5893 dpurdie 250
   Else
251
      '---- Unknown input type
252
        Response.write "Internal error. Unknown update_type!" & "<br>" 'TODO
253
        Err.number = 1
129 ghuddy 254
   End If
121 hknight 255
 
256
 
129 ghuddy 257
   If Err.number = 0 Then
258
      Call Update_Mod_Details ( Request("pv_id") )
259
   End If
121 hknight 260
 
261
 
129 ghuddy 262
   If Err.number <> 0 Then
263
      OraSession.RollBack
264
      Call RaiseMsg ( enum_MSG_ERROR, Err.description &"<br>"& Err.Source )
265
   Else
266
      OraSession.CommitTrans
267
   End If
121 hknight 268
 
5957 dpurdie 269
   Call Destroy_All_Objects
129 ghuddy 270
   Response.Redirect("dependencies.asp?pv_id="& Request("pv_id") &"&rtag_id="& Request("rtag_id"))
119 ghuddy 271
Else
1376 dpurdie 272
   Response.write "Some mandatory parameters are missing!" & "<br>" 'TODO
4955 dpurdie 273
   Response.write QSTR_FullQuery
119 ghuddy 274
End If
275
%>
276
<!-- DESTRUCTOR ------->
121 hknight 277
<!--#include file="common/destructor.asp"-->