Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

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