Skip to content

Commit 1c3bb4d

Browse files
committed
port CreateProduction from CCR
1 parent 9024dac commit 1c3bb4d

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

cls/SourceControl/Git/Production.cls

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,20 +227,16 @@ ClassMethod IsEnsPortal() As %Boolean
227227
/// Perform check if Production Decomposition logic should be used for given item
228228
ClassMethod IsProductionClass(className As %String, nameMethod As %String) As %Boolean
229229
{
230-
if $$$comClassDefined(className) {
230+
if (className '= "") && $$$comClassDefined(className) {
231231
return $classmethod(className, "%Extends", "Ens.Production")
232232
} else {
233233
set filename = $classmethod($$SrcCtrlCls^%buildccr, nameMethod, className_".CLS")
234234
if ##class(%File).Exists(filename) {
235235
$$$ThrowOnError($System.OBJ.Load(filename))
236236
}
237237
set classDef = ##class(%Dictionary.ClassDefinition).%OpenId(className)
238-
if $isobject(classDef) {
239-
for key=1:1:classDef.XDatas.Count() {
240-
if classDef.XDatas.GetAt(key).Name = "ProductionDefinition" {
241-
return 1
242-
}
243-
}
238+
if $isobject(classDef) && ##class(%Dictionary.ClassDefinition).%ExistsId(classDef.Super) {
239+
return $classmethod(classDef.Super, "%Extends", "Ens.Production")
244240
}
245241
}
246242
return 0
@@ -316,4 +312,26 @@ ClassMethod RemoveItem(internalName, noFolders As %Boolean = 0) As %Status
316312
return sc
317313
}
318314

315+
/// Given internal name for a Production Settings PTD, creates the corresponding Production
316+
/// Class if it does not already exist in this namespace
317+
ClassMethod CreateProduction(productionName As %String, superClasses = "") As %Status
318+
{
319+
set classDef = ##class(%Dictionary.ClassDefinition).%New(productionName)
320+
if superClasses '= "" {
321+
set classDef.Super = superClasses
322+
} else {
323+
set classDef.Super = "Ens.Production"
324+
}
325+
set productionXData = ##class(%Dictionary.XDataDefinition).%New()
326+
set productionXData.Name = "ProductionDefinition"
327+
set sc = productionXData.Data.WriteLine("<Production Name="""_productionName_"""/>")
328+
if $$$ISERR(sc) return sc
329+
set sc = classDef.XDatas.Insert(productionXData)
330+
if $$$ISERR(sc) return sc
331+
set sc = classDef.%Save()
332+
if $$$ISERR(sc) return sc
333+
set sc = $System.OBJ.Compile(productionName)
334+
return sc
335+
}
336+
319337
}

0 commit comments

Comments
 (0)