Skip to content

Commit ade892d

Browse files
committed
enh: add mapping token setting which allows defining a namespace type to be used in mappings
1 parent 0e44803 commit ade892d

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111
- Expanded Baseline Export to include custom HL7, X12, ASTM schemas and Lookup Tables (#693)
12-
- Mapping configuration expands \<namespace\> parameter to support namespace-specific mappings (#710)
12+
- Mapping configuration expands \<namespace\> and \<token\> parameters to better support multi-namespace solutions (#710)
1313
- Settings page includes a test of the connection to the remote (#746)
1414

1515
### Fixed

cls/SourceControl/Git/Settings.cls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ Property environmentName As %String(MAXLEN = "") [ InitialExpression = {##class(
6565
/// Whether the branch should or should not be locked down from changing namespaces
6666
Property lockBranch As %Boolean [ InitialExpression = {##class(SourceControl.Git.Utils).LockBranch()} ];
6767

68+
/// (Optional) A namespace-specific string that may be included in mapping configurations as <token> to support multi-namespace repositories
69+
Property mappingsToken As %String(MAXLEN = "") [ InitialExpression = {##class(SourceControl.Git.Utils).MappingsToken()} ];
70+
6871
Property Mappings [ MultiDimensional ];
6972

7073
Property favoriteNamespaces As %DynamicArray;
@@ -157,6 +160,7 @@ Method %Save() As %Status
157160
set @storage@("settings", "basicMode") = ..systemBasicMode
158161
set @storage@("settings", "environmentName") = ..environmentName
159162
set @storage@("settings", "lockBranch") = ..lockBranch
163+
set @storage@("settings", "mappingsToken") = ..mappingsToken
160164
if ..basicMode = "system" {
161165
kill @storage@("settings", "user", $username, "basicMode")
162166
} else {
@@ -519,3 +523,4 @@ Method SaveDefaults() As %Boolean
519523
}
520524

521525
}
526+

cls/SourceControl/Git/Utils.cls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ ClassMethod LockBranch() As %Boolean
190190
quit $get(@..#Storage@("settings","lockBranch"),0)
191191
}
192192

193+
ClassMethod MappingsToken() As %String
194+
{
195+
quit $get(@..#Storage@("settings","mappingsToken"),"")
196+
}
197+
193198
ClassMethod IsLIVE() As %Boolean
194199
{
195200
quit ..EnvironmentName()="LIVE"
@@ -2427,6 +2432,7 @@ ClassMethod ExpandMappingParameters(MapDirectory, Settings As SourceControl.Git.
24272432
1: Settings.environmentName)
24282433
,"l"))
24292434
set expandedDir = $replace(expandedDir,"<namespace>", $zconvert($namespace,"l"))
2435+
set expandedDir = $replace(expandedDir,"<token>", Settings.mappingsToken)
24302436
return expandedDir
24312437
}
24322438

@@ -3216,3 +3222,4 @@ ClassMethod IsSchemaStandard(pName As %String = "") As %Boolean [ Internal ]
32163222
}
32173223

32183224
}
3225+

csp/gitprojectsettings.csp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ body {
109109
set $Property(settings,param) = $Get(%request.Data(param,1))
110110
}
111111
if ('settings.settingsUIReadOnly) {
112-
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName" {
112+
for param="gitBinPath","namespaceTemp","privateKeyFile","pullEventClass","percentClassReplace", "defaultMergeBranch","environmentName","mappingsToken" {
113113
set $Property(settings,param) = $Get(%request.Data(param,1))
114114
}
115115

@@ -274,7 +274,7 @@ body {
274274
</div>
275275

276276
<div class="form-group row mb-3">
277-
<label for="namespaceTemp" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to you project">Git Repo Root Directory<br/></label>
277+
<label for="namespaceTemp" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="Absolute path to your project">Git Repo Root Directory<br/></label>
278278
<server>
279279
set dir = ##class(%File).NormalizeDirectory(settings.namespaceTemp)
280280
if (settings.namespaceTemp '= "") && ##class(%File).DirectoryExists(dir_".git") {
@@ -506,6 +506,12 @@ body {
506506
</div>
507507
</div>
508508
</div>
509+
<div class="form-group row mb-3">
510+
<label for="mappingsToken" class="offset-sm-1 col-sm-3 col-form-label" data-toggle="tooltip" data-placement="top" title="(Optional) A namespace-specific string that may be included in mapping configurations as <token> to support multi-namespace repositories">Mappings Token</label>
511+
<div class="col-sm-7">
512+
<input type="text" class="form-control" id="mappingsToken" name="mappingsToken" value='#(..EscapeHTML(settings.mappingsToken))#'>
513+
</div>
514+
</div>
509515

510516
<div class="form-group row mb-3 mapping-input-group">
511517
<div class="offset-sm-1 col-sm-3">

test/UnitTest/SourceControl/Git/NameTest.cls

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ Method TestParamExpansion()
7070
set $$$SourceMapping("ESD","*") = "config/<env>/"
7171
set $$$SourceMapping("ESD","*","NoFolders") = 1
7272
set $$$SourceMapping("CLS","*") = "<namespace>/cls/"
73+
set $$$SourceMapping("INC","*") = "<token>/inc/"
7374
set settings = ##class(SourceControl.Git.Settings).%New()
7475
set oldEnvName = settings.environmentName
7576
set settings.environmentName = "TEST"
77+
set settings.mappingsToken = "mdi"
7678
$$$ThrowOnError(settings.%Save())
7779
do $$$AssertEquals(##class(SourceControl.Git.Utils).Name("Ens.Config.DefaultSettings.esd"),"config/test/Ens.Config.DefaultSettings.esd")
7880
do $$$AssertEquals(##class(SourceControl.Git.Utils).Name("test.class.cls"),$zconvert($namespace,"l")_"/cls/test/class.cls")
81+
do $$$AssertEquals(##class(SourceControl.Git.Utils).Name("test.routine.inc"),"mdi/inc/test/routine.inc")
7982
} catch err {
8083
do $$$AssertStatusOK(err.AsStatus())
8184
}

0 commit comments

Comments
 (0)