1
- /// This class serves as an intermediary for managing Source Control for Productions.
2
- /// Included is handling for exporting Productions as individual pieces of settings
3
- /// and importing individual item settings.
1
+ /// This is a replica of %Studio.SourceControl.Production for backwards compatibility with older IRIS versions.
4
2
Class SourceControl .Git .Production Extends %RegisteredObject
5
3
{
6
4
5
+ /// This Parameter should be updated when synced from Perforce
6
+ Parameter SrcVer = " $Id: //custom_ccrs/_common/config/cls/Studio/SourceControl/Production.xml#3 $" ;
7
+
8
+ /// Revision number of this class when compiled as part of the //custom_ccrs/_common/config/... branch.
9
+ /// This version will not be updated (by design) when the class is integrated to other branches.
10
+ /// This allows the user to tell what version of the Studio client tools are in use.
11
+ Parameter Version = 4 ;
12
+
7
13
/// Exports settings for a given Production and each Config Item from
8
14
/// the ProductionDefinition as separate XMLs. These are exported to
9
15
/// the appropriate file based on nameMethod of the source control class
@@ -159,9 +165,16 @@ ClassMethod ExportPTD(internalName As %String, nameMethod) As %Status
159
165
/// Imports a PTD into a produciton given an external name and produciton name
160
166
ClassMethod ImportPTD (externalName As %String , productionName As %String ) As %Status
161
167
{
162
- set rollbackFile = ##class (%File ).TempFilename ()
163
- set sc = ##class (Ens.Deployment.Deploy ).DeployCode (externalName ,productionName ,0 ,rollbackFile )
164
- do ##class (%File ).Delete (rollbackFile )
168
+ try {
169
+ set ^IRIS .Temp (" sscProd" ,$job ," bypassLock" ) = 1
170
+ set rollbackFile = ##class (%File ).TempFilename ()
171
+ set sc = ##class (Ens.Deployment.Deploy ).DeployCode (externalName ,productionName ,0 ,rollbackFile )
172
+ do ##class (%File ).Delete (rollbackFile )
173
+ kill ^IRIS .Temp (" sscProd" ,$job ," bypassLock" )
174
+ } catch err {
175
+ kill ^IRIS .Temp (" sscProd" ,$job ," bypassLock" )
176
+ set sc = err .AsStatus ()
177
+ }
165
178
return sc
166
179
}
167
180
@@ -171,7 +184,7 @@ ClassMethod ImportPTDsDir(directory As %String, isDecompMethod As %String = "")
171
184
set sc = $$$OK
172
185
set rs = ##class (%ResultSet ).%New (" %File:FileSet" )
173
186
$$$ThrowOnError(rs .Execute (directory , " *.xml" , " " , 1 ))
174
- $$$ThrowSQLIfError (rs .%SQLCODE , rs .%Message )
187
+ throw : rs . %SQLCODE < 0 ##class ( %Exception.SQL ). CreateFromSQLCODE (rs .%SQLCODE , rs .%Message )
175
188
while rs .Next () {
176
189
set path = rs .Data (" Name" )
177
190
set type = rs .Data (" Type" )
@@ -347,13 +360,16 @@ ClassMethod IsProductionClass(className As %String, nameMethod As %String) As %B
347
360
}
348
361
// check if there is a class export for this Production, load it for class definition
349
362
set filename = $classmethod (##class (%Studio.SourceControl.Interface ).SourceControlClassGet (), nameMethod , className _" .CLS" )
350
- if ##class (%File ).Exists (filename ) {
363
+ if ##class (%File ).Exists (filename ) && ( ##class ( %File ). GetFileSize ( filename ) '= 0 ) {
351
364
$$$ThrowOnError($System .OBJ .Load (filename ))
352
365
}
353
366
// if Production exists as a class definition on the server, check if extending Ens.Production
354
367
set classDef = ##class (%Dictionary.ClassDefinition ).%OpenId (className )
355
- if $isobject (classDef ) && ##class (%Dictionary.ClassDefinition ).%ExistsId (classDef .Super ) {
356
- return $classmethod (classDef .Super , " %Extends" , " Ens.Production" )
368
+ if $isobject (classDef ) {
369
+ for i =1 :1 :classDef .XDatas .Count () {
370
+ set xdata = classDef .XDatas .GetAt (i )
371
+ if xdata .Name = " ProductionDefinition" return 1
372
+ }
357
373
}
358
374
}
359
375
return 0
@@ -505,6 +521,7 @@ ClassMethod GetUserProductionChanges(productionName As %String, ByRef items)
505
521
/// Executes a SQL query without privilege checking if possible on this IRIS version
506
522
ClassMethod ExecDirectNoPriv (sql , args ...) As %SQL .StatementResult
507
523
{
524
+ // once minimum version is IRIS 2021.1.3, remove and just use %ExecDirectNoPriv
508
525
try {
509
526
set rs = ##class (%SQL.Statement ).%ExecDirectNoPriv (,sql ,args ...)
510
527
} catch err {
@@ -513,4 +530,24 @@ ClassMethod ExecDirectNoPriv(sql, args...) As %SQL.StatementResult
513
530
return rs
514
531
}
515
532
533
+ /// Handles all compile-time logic for this class
534
+ ClassMethod OnToolsCompile () [ CodeMode = objectgenerator , Internal ]
535
+ {
536
+ For i = 1 :1 :%class .Parameters .Count () {
537
+ If %class .Parameters .GetAt (i ).Name = " SrcVer" Set valSrcVer = %class .Parameters .GetAt (i ).Default
538
+ If %class .Parameters .GetAt (i ).Name = " Version" Set indexVersion =i
539
+ }
540
+ If $D (indexVersion )&&($G (valSrcVer )[" //custom_ccrs/_common/config/" ) {
541
+ Set %class .Parameters .GetAt (indexVersion ).Default = $P ($G (valSrcVer )," #" ,2 )+1
542
+ Do %class .Parameters .GetAt (indexVersion ).%Save ()
543
+ }
544
+ Quit $$$OK
545
+ }
546
+
547
+ /// Returns value the Major.Minor version for this instance, so it can be used in comparison code which makes sure certain features are used in appropriate versions
548
+ ClassMethod InstanceVersion () As %Numeric [ CodeMode = expression ]
549
+ {
550
+ $P ($SYSTEM .Version .GetNumber ()," ." ,1 ,2 )
551
+ }
552
+
516
553
}
0 commit comments