Skip to content

Commit

Permalink
Merge pull request #30 from intersystems/fix-compatibility-with-v0.9
Browse files Browse the repository at this point in the history
feat: make isc.rest compatible with IPM 0.9
  • Loading branch information
isc-tleavitt authored Dec 5, 2024
2 parents 7778d78 + 8f2122b commit 83d7d7a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased - 1.2.2+snapshot]

### Added
-
- Added compatibility with IPM 0.9+

### Changed
-
Expand Down
32 changes: 24 additions & 8 deletions preload/cls/pkg/isc/rest/lifecycle.cls
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,40 @@ ClassMethod RunOnLoad() [ CodeMode = objectgenerator ]
Quit:$Extract($Namespace)="^" $$$OK
Set sc = $$$OK
Try {
Set sourceDB = ##class(%ZPM.PackageManager.Developer.Utils).GetRoutineDatabase($Namespace)
Set sc = ##class(%ZPM.PackageManager.Developer.Utils).AddGlobalMapping($Namespace,"oddPKG(""%pkg.isc.rest"")",sourceDB)
If ##class(%Dictionary.ClassDefinition).%ExistsId("%IPM.Utils.Module") {
Set utilClass = "%IPM.Utils.Module"
} Else {
Set utilClass = "%ZPM.PackageManager.Developer.Utils"
}
Set sourceDB = $ClassMethod(utilClass, "GetRoutineDatabase", $Namespace)
Set sc = $ClassMethod(utilClass, "AddGlobalMapping", $Namespace, "oddPKG(""%pkg.isc.rest"")", sourceDB)
$$$ThrowOnError(sc)
Set sc = ##class(%ZPM.PackageManager.Developer.Utils).AddPackageMapping($Namespace,"%pkg.isc.rest",sourceDB)
Set sc = $ClassMethod(utilClass, "AddPackageMapping", $Namespace, "%pkg.isc.rest", sourceDB)
$$$ThrowOnError(sc)
} Catch e {
Set sc = e.AsStatus()
}
Return sc
}

ClassMethod GetUtilClass() As %String
{
If ##class(%Dictionary.ClassDefinition).%ExistsId("%IPM.Utils.Module") {
Return "%IPM.Utils.Module"
} Else {
Return "%ZPM.PackageManager.Developer.Utils"
}
}

Method %Reload(ByRef pParams) As %Status
{
Set sc = $$$OK
Try {
Set sourceDB = ##class(%ZPM.PackageManager.Developer.Utils).GetRoutineDatabase($Namespace)
Set sc = ##class(%ZPM.PackageManager.Developer.Utils).AddGlobalMapping($Namespace,"oddPKG(""%pkg.isc.rest"")",sourceDB)
Set utilClass = ..GetUtilClass()
Set sourceDB = $ClassMethod(utilClass, "GetRoutineDatabase", $Namespace)
Set sc = $ClassMethod(utilClass, "AddGlobalMapping", $Namespace, "oddPKG(""%pkg.isc.rest"")", sourceDB)
$$$ThrowOnError(sc)
Set sc = ##class(%ZPM.PackageManager.Developer.Utils).AddPackageMapping($Namespace,"%pkg.isc.rest",sourceDB)
Set sc = $ClassMethod(utilClass, "AddPackageMapping", $Namespace, "%pkg.isc.rest", sourceDB)
$$$ThrowOnError(sc)
// Ensure super is called AFTER mappings are set up
Set sc = ##super(.pParams)
Expand All @@ -40,8 +55,9 @@ Method %Clean(ByRef pParams) As %Status
Try {
Set sc = ##super(.pParams)
$$$ThrowOnError(sc)
Do ##class(%ZPM.PackageManager.Developer.Utils).RemoveGlobalMapping($Namespace,"oddPKG(""%pkg.isc.rest"")")
Do ##class(%ZPM.PackageManager.Developer.Utils).RemovePackageMapping($Namespace,"%pkg.isc.rest")
Set utilClass = ..GetUtilClass()
Do $ClassMethod(utilClass, "RemoveGlobalMapping", $Namespace, "oddPKG(""%pkg.isc.rest"")")
Do $ClassMethod(utilClass, "RemovePackageMapping", $Namespace,"%pkg.isc.rest")
} Catch e {
Set sc = e.AsStatus()
}
Expand Down

0 comments on commit 83d7d7a

Please sign in to comment.