Skip to content

Commit 3e649bb

Browse files
authored
Merge pull request #380 from daimor/vscode-format-files
Support for Atelier/VSCode format files
2 parents 0aa439f + b82584f commit 3e649bb

File tree

17 files changed

+3306
-55
lines changed

17 files changed

+3306
-55
lines changed

src/%ZPM/PackageManager/Developer/File.cls

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,35 @@ ClassMethod FindFiles(pPath As %String, pWildcards As %String = "", Output pList
182182
Return pList
183183
}
184184

185+
/// Check if file exists but case insensetive
186+
ClassMethod Exists(ByRef pFilename, Output pReturn) As %Boolean
187+
{
188+
If ##class(%File).Exists(pFilename) {
189+
Return 1
190+
}
191+
Set tDirectory = ##class(%File).ParentDirectoryName(pFilename)
192+
If '##class(%File).DirectoryExists(tDirectory) {
193+
Return 0
194+
}
195+
Set tName = $Piece(pFilename, tDirectory, 2, *)
196+
Set tFileName = $Piece(tName, ".", 1, * - 1)
197+
Set tFileExt = $Piece(tName, ".", *)
198+
for tExt = $$$LOWER(tFileExt), $$$UPPER(tFileExt) {
199+
If ##class(%File).Exists(tDirectory _ tFileName _ "." _ tExt) {
200+
Set pFilename = tDirectory _ tFileName _ "." _ tExt
201+
Return 1
202+
}
203+
}
204+
set tNameLower = $$$LOWER(tName)
205+
Set rs = ##class(%File).FileSetFunc(tDirectory, "*", , 0)
206+
While rs.%Next() {
207+
set tItemNameLower = $$$LOWER(rs.ItemName)
208+
If tItemNameLower = tNameLower {
209+
Set pFilename = tDirectory _ rs.ItemName
210+
Return 1
211+
}
212+
}
213+
Return 0
214+
}
215+
185216
}

src/%ZPM/PackageManager/Developer/Lifecycle/Abstract.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ ClassMethod GetDefaultResourceProcessor(pResourceName As %String) As %Dictionary
8282
"LUT":"Interoperability",
8383
"X12":"Interoperability",
8484
"ESD":"Interoperability",
85+
"HL7":"Interoperability",
8586
"DTL":"Class",
8687
"BPL":"Class",
8788
:"Document")

src/%ZPM/PackageManager/Developer/Lifecycle/Base.cls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ Method GetResourceRelativePath(pResource As %String, pExtension As %String) As %
15221522
"CLS":"cls/",
15231523
"GBL":"gbl/",
15241524
"X12":"i14y/",
1525+
"HL7":"i14y/",
15251526
"LUT":"i14y/",
15261527
"ESD":"i14y/",
15271528
"DTL":"cls/",

src/%ZPM/PackageManager/Developer/Processor/Default/DeepSeeItem.cls

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -49,58 +49,53 @@ Method OnExportItem(pFullExportPath As %String, pItemName As %String, ByRef pIte
4949

5050
Method OnPhase(pPhase As %String, ByRef pParams, Output pResourceHandled As %Boolean = 0) As %Status
5151
{
52-
Set tSC = $$$OK
53-
Set pResourceHandled = 0
54-
Try {
55-
Set tVerbose = $Get(pParams("Verbose"),0)
56-
Set tDeveloperMode = $Get(pParams("DeveloperMode"),0)
57-
Set tName = $Piece(..ResourceReference.Name,".",1,*-1)
58-
Set tRoot = ..ResourceReference.Module.Root
59-
60-
If (pPhase = "Reload") {
61-
If '..ResourceReference.Generated,'..ResourceReference.Preload {
62-
Set tSubDirectory = $Select(..ResourceReference.Preload:"preload/",1:"")
63-
Set tResourceDirectory = tRoot_"/"_tSubDirectory
64-
65-
Set tSourceRoot = ..ResourceReference.Module.SourcesRoot
66-
If tSourceRoot'="","\/"'[$Extract(tSourceRoot, *) {
67-
Set tSourceRoot = tSourceRoot _ "/"
68-
}
69-
70-
Set tDirectory = ..Directory
71-
If tDirectory'="","\/"'[$Extract(tDirectory, *) {
72-
Set tDirectory = tDirectory _ "/"
73-
} Else {
74-
Set tDirectory = "dfi/"
75-
}
76-
77-
Set tResourceDirectory = ##class(%File).NormalizeDirectory(tResourceDirectory_tSourceRoot_tDirectory)
52+
Set tInScope = ..ResourceReference.IsInScope(pPhase,.tInCurrentPhase)
53+
If (..ResourceReference.Name '[ "*") || '(((pPhase = "Reload") && tInScope) || tInCurrentPhase) || ..ResourceReference.Generated || ..ResourceReference.Preload {
54+
Quit ##super(pPhase, .pParams, .pResourceHandled)
55+
}
56+
57+
Set tVerbose = $Get(pParams("Verbose"), 0)
58+
Set tSC = $$$OK
59+
Set pResourceHandled = 0
60+
try {
61+
Set tNameExt = "." _ $$$lcase($Piece(..ResourceReference.Name, ".", *))
62+
Set tName = $Piece(..ResourceReference.Name, ".", 1, *-1)
63+
Set tName = $Translate(tName, "*"_..FilenameTranslateIdentifier, "*"_..FilenameTranslateAssociator)
64+
Set tRoot = ..ResourceReference.Module.Root
65+
66+
Set tSubDirectory = $Select(..ResourceReference.Preload:"preload/",1:"")
67+
Set tResourceDirectory = tRoot _ "/" _ tSubDirectory
68+
69+
Set tSourceRoot = ..ResourceReference.Module.SourcesRoot
70+
If tSourceRoot'="","\/"'[$Extract(tSourceRoot, *) {
71+
Set tSourceRoot = tSourceRoot _ "/"
72+
}
7873

79-
If (tName [ "*") {
80-
Set tName = $Translate(tName, "*"_..FilenameTranslateIdentifier, "*"_..FilenameTranslateAssociator)
81-
Set tWildcards = tName_".xml"
82-
If $$$isUNIX Set tWildcards = $$$ucase(tWildcards)_";"_$$$lcase(tWildcards)
83-
Do ##class(%ZPM.PackageManager.Developer.File).FindFiles(tResourceDirectory, tWildcards, .tList)
84-
} Else {
85-
Set tName = $Translate(tName, ..FilenameTranslateIdentifier, ..FilenameTranslateAssociator) _ ".xml"
86-
Set tList($Increment(tList)) = $ListBuild(tName, tResourceDirectory _ tName)
87-
}
74+
Set tDirectory = ..Directory
75+
If tDirectory'="","\/"'[$Extract(tDirectory, *) {
76+
Set tDirectory = tDirectory _ "/"
77+
} Else {
78+
Set tDirectory = "dfi/"
79+
}
8880

89-
For i=1:1:tList {
90-
Set $ListBuild(tDocName, tResourcePath) = tList(i)
81+
Set tResourceDirectory = ##class(%File).NormalizeDirectory(tResourceDirectory_tSourceRoot_tDirectory)
9182

92-
Set tSC = $System.OBJ.Load(tResourcePath,$Select(tVerbose:"/display",1:"/nodisplay")_"/nocompile")
93-
If $$$ISERR(tSC) {
94-
Quit
95-
}
96-
}
97-
}
98-
}
83+
Set tFileExt = ".xml"
84+
Set tWildcards = tName _ tFileExt _ ";" _ tName _ tNameExt
85+
If $$$isUNIX {
86+
Set tWildcards = tWildcards _ tName _ $$$ucase(tFileExt) _ ";" _ tName _ $$$ucase(tNameExt)
87+
}
88+
Do ##class(%ZPM.PackageManager.Developer.File).FindFiles(tResourceDirectory, tWildcards, .tList)
89+
For i=1:1:tList {
90+
Set $ListBuild(tDocName, tResourcePath) = tList(i)
9991

100-
} Catch e {
101-
Set tSC = e.AsStatus()
102-
}
103-
Quit tSC
92+
$$$ThrowOnError(..OnLoad(tResourcePath, tVerbose, tInCurrentPhase, .tLoadedList, .pParams))
93+
}
94+
}
95+
catch ex {
96+
Set tSC = e.AsStatus()
97+
}
98+
Quit tSC
10499
}
105100

106101
Method OnResolveChildren(ByRef pResourceArray) As %Status

src/%ZPM/PackageManager/Developer/Processor/Default/Document.cls

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Method DirectorySet(pValue As %String) As %Status
5656

5757
Method OnPhase(pPhase As %String, ByRef pParams, Output pResourceHandled As %Boolean = 0) As %Status
5858
{
59+
5960
Set tSC = $$$OK
6061
Set pResourceHandled = 0
6162
Try {
@@ -119,9 +120,21 @@ Method OnPhase(pPhase As %String, ByRef pParams, Output pResourceHandled As %Boo
119120
}
120121

121122
If '..ResourceReference.Preload {
122-
Set tFileExtension = $Select(..LoadAsDirectory: "", 1: "." _ ..FilenameExtension)
123-
Set tResourcePath = ##class(%File).NormalizeFilename(tResourceDirectory _ tSubDirectory _ $Translate(tName, ..FilenameTranslateIdentifier, ..FilenameTranslateAssociator)) _ tFileExtension
123+
Set tFileExtension = ""
124+
Set tResourcePath = ##class(%File).NormalizeFilename(tResourceDirectory _ tSubDirectory _ $Translate(tName, ..FilenameTranslateIdentifier, ..FilenameTranslateAssociator))
124125
If '..LoadAsDirectory {
126+
Set tItemFileExtension = $$$lcase("." _ $Piece(..ResourceReference.Name, ".", *))
127+
Set tFileExtension = $$$lcase("." _ ..FilenameExtension)
128+
For tFileExtension = tFileExtension,tItemFileExtension {
129+
Set temp = tResourcePath _ tFileExtension
130+
If ##class(%ZPM.PackageManager.Developer.File).Exists(.temp) {
131+
Set tFileExtension = "." _ $Piece(temp, ".", *)
132+
Quit
133+
}
134+
}
135+
136+
Set tResourcePath = tResourcePath _ tFileExtension
137+
125138
If ($$$lcase(tFileExtension)'=".xml")&&('##class(%File).Exists(tResourcePath)) {
126139
Set tResourcePathXML = tResourcePath
127140
Set $Piece(tResourcePathXML, ".", *) = "xml"
@@ -139,12 +152,12 @@ Method OnPhase(pPhase As %String, ByRef pParams, Output pResourceHandled As %Boo
139152
}
140153
}
141154

142-
If '##class(%File).Exists(tResourcePath) {
155+
If '##class(%ZPM.PackageManager.Developer.File).Exists(.tResourcePath) {
143156
Set tSC = $$$ERROR($$$GeneralError, "Resource path '" _ tResourcePath _ "' not found")
144157
Continue
145158
}
146159

147-
$$$ThrowOnError(..OnLoad(tResourcePath,tVerbose,tInCurrentPhase,.tLoadedList))
160+
$$$ThrowOnError(..OnLoad(tResourcePath,tVerbose,tInCurrentPhase,.tLoadedList,.pParams))
148161

149162
Set tSC = ##class(%ZPM.PackageManager.Developer.LoadedResource).TrackResourceNames(..ResourceReference.Module.Name,..ResourceReference.UniqueName,tLoadedList)
150163
$$$ThrowOnError(tSC)
@@ -379,6 +392,7 @@ Method OnConfigureMappings(ByRef pParams) As %Status
379392
Method OnLoad(pFullResourcePath As %String, pVerbose As %Boolean, pCompile As %Boolean = 0, Output pLoadedList As %String, ByRef pParams As %String) As %Status
380393
{
381394
Set pLoadedList = ""
395+
Set tVerbose = $Get(pParams("Verbose"),0)
382396
Set tSC = $$$OK
383397
Try {
384398
// Workaround: need to clean up after other UDL import/export operations
@@ -399,8 +413,40 @@ Method OnLoad(pFullResourcePath As %String, pVerbose As %Boolean, pCompile As %B
399413
Set pLoadedList = ""
400414
Set tSC = $$Import^%apiRTN(pFullResourcePath,"replace,compile="_pCompile,,,.tResult,$Select(pVerbose:"d",1:"-d"))
401415
} Else {
402-
Set tSC = $System.OBJ.Load(pFullResourcePath,tFlags,,.pLoadedList)
403-
$$$ThrowOnError(tSC)
416+
Set tProcessed = 0
417+
set fileExt = $$$UPPER($Piece(pFullResourcePath, ".", *))
418+
if '$LISTFIND($LB("CLS", "MAC"), fileExt), ##class(%RoutineMgr).UserType(..ResourceReference.Name, .docclass, .doctype) {
419+
try {
420+
set stream = ##class(%Stream.FileCharacter).%New()
421+
$$$ThrowOnError(stream.LinkToFile(pFullResourcePath))
422+
try {
423+
Quit:'##class(%XML.XPATH.Document).CreateFromStream(stream, .tDocument)
424+
Quit:'$ISOBJECT(tDocument)
425+
Quit:'tDocument.EvaluateExpression("/Export/Document", "text()", .tRes)
426+
if $IsObject(tRes),tRes.Size {
427+
Set tSC = $System.OBJ.Load(pFullResourcePath,tFlags,,.pLoadedList)
428+
Set tProcessed = 1
429+
}
430+
} catch ex { }
431+
if 'tProcessed {
432+
try {
433+
Write:tVerbose !,"Loading file " _ pFullResourcePath _ " as " _ docclass
434+
set routineMgr = ##class(%RoutineMgr).%OpenId(..ResourceReference.Name)
435+
do routineMgr.Code.Rewind()
436+
do routineMgr.Code.CopyFrom(stream)
437+
$$$ThrowOnError(routineMgr.%Save())
438+
Write:tVerbose !,"Imported document: ", ..ResourceReference.Name, !, "Load finished successfully.", !
439+
Set tProcessed = 1
440+
} catch ex { }
441+
}
442+
} catch ex {
443+
#; Default way
444+
}
445+
}
446+
If 'tProcessed {
447+
Set tSC = $System.OBJ.Load(pFullResourcePath,tFlags,,.pLoadedList)
448+
$$$ThrowOnError(tSC)
449+
}
404450
}
405451
$$$ThrowOnError(..OnLoadDeployed(.pParams, .pLoadedList))
406452
If $Data(tResourceKey)>1 {

src/%ZPM/PackageManager/Developer/Processor/Default/Interoperability.cls

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,18 @@ Property FilenameTranslateAssociator As %String [ InitialExpression = "/___" ];
1010
/// Extension for individual filename(s) that comprise this resource
1111
Property FilenameExtension As %String [ InitialExpression = "xml" ];
1212

13+
Method DirectoryGet() As %String
14+
{
15+
If i%DirectoryDefined Return i%Directory
16+
Set tRoot = ##class(%File).NormalizeDirectory(..ResourceReference.Module.SourcesRoot, ..ResourceReference.Module.Root)
17+
For name = "i14y", "misc" {
18+
If ##class(%File).DirectoryExists(##class(%File).NormalizeDirectory(name, tRoot)) {
19+
Set i%DirectoryDefined = 1
20+
Set i%Directory = name _ "/"
21+
Return i%Directory
22+
}
23+
}
24+
Quit "i14y/"
25+
}
26+
1327
}

tests/integration_tests/Test/PM/Integration/Resources.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Class Test.PM.Integration.Resources Extends %UnitTest.TestCase
33

44
Method TestResourceTypes()
55
{
6-
If ('##class(%EnsembleMgr).IsHealthShareInstalled()) {
6+
If ('$ListFind($system.Version.GetISCComponents(), "Health")) {
77
Quit $$$OK
88
}
99

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0"?>
2+
3+
<pivot xmlns="http://www.intersystems.com/deepsee/library" name="Countries_bubble" folderName="dfi" title="" description="" keywords="" owner="" shared="true" public="false" locked="false" resource="" timeCreated="2020-04-19T19:56:18.229Z" createdBy="_SYSTEM" category="" bookCover="" mdx="" cellWidth="120" columnHeaderStyle="" rowHeaderStyle="" cellStyle="" rowLabelSpan="true" columnLabelSpan="true" cellHeight="22" showEmptyRows="false" showEmptyColumns="false" cubeName="COVID03162020" caption="" listing="" listingRows="" showStatus="true" canDrillDown="true" pageSize="100" colorScale="" rowTotals="false" columnTotals="false" rowTotalAgg="sum" columnTotalAgg="sum" rowTotalSource="page" showZebra="false" showRowCaption="true" printTitle="" printSubtitle="" printSubtitleOn="" showUser="" printPageSize="" printOrientation="1" printMarginTop="" printMarginLeft="" printMarginRight="" printMarginBottom="" printLabelWidth="" printCellWidth="" autoExecute="true" previewMode="false" manualMode="false" userMDX="" chartMarginTop="" chartMarginLeft="" chartMarginRight="" chartMarginBottom="" maxRows="" borderLeftCell="" borderRightCell="" borderTopCell="" borderBottomCell="" borderLeftCol="" borderRightCol="" borderTopCol="" borderBottomCol="" borderLeftRow="" borderRightRow="" borderTopRow="" borderBottomRow="" fontFamilyCell="" fontSizeCell="" fontFamilyCol="" fontSizeCol="" fontFamilyRow="" fontSizeRow="" showFilters="" showListingFilters="" showDate="" listingFontSize="" showZebraStripes="" filterTableStyle="" filterTableCaptionStyle="" filterTableItemStyle="" nowDisplayFormat="" measureLocation="columns" hideMeasures="1" backgroundImage="" backgroundOpacity=".12">
4+
<rowAxisOptions spec="" key="" value="" text="" headEnabled="false" headCount="" filterEnabled="false" filterExpression="" orderEnabled="false" orderExpression="" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
5+
</rowAxisOptions>
6+
<columnAxisOptions spec="" key="" value="" text="" headEnabled="false" headCount="" filterEnabled="false" filterExpression="" orderEnabled="false" orderExpression="" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
7+
</columnAxisOptions>
8+
<rowLevel spec="[CountryRegion].[H1].[CountryRegion].Members" key="" value="" text="CountryRegion" headEnabled="true" headCount="10" filterEnabled="false" filterExpression="" orderEnabled="true" orderExpression="Measures.[Confirmed]" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
9+
</rowLevel>
10+
<sqlRestriction></sqlRestriction>
11+
<measure spec="[Measures].[Confirmed]" key="" value="" text="Confirmed" headEnabled="false" headCount="" filterEnabled="false" filterExpression="" orderEnabled="false" orderExpression="" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="#,###" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
12+
</measure>
13+
<measure spec="[Measures].[Recovered]" key="" value="" text="Recovered" headEnabled="false" headCount="" filterEnabled="false" filterExpression="" orderEnabled="false" orderExpression="" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="#,###" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
14+
</measure>
15+
<measure spec="[Measures].[Deaths]" key="" value="" text="Deaths" headEnabled="false" headCount="" filterEnabled="false" filterExpression="" orderEnabled="false" orderExpression="" orderDirection="BDESC" aggEnabled="false" aggFunction="" aggFunctionParm="" levelCaption="" levelFormat="#,###" levelSummary="" levelType="" drillLevel="0" advanced="false" levelStyle="" levelHeaderStyle="" suppress8020="false" drilldownSpec="" enabled="true">
16+
</measure>
17+
<calculatedMember dimension="MEASURES" memberName="Death2Confirmed" valueExpression="[Measures].[Deaths]/ [Measures].[Confirmed]" formatString="%#.##;;;;" solveOrder="0"></calculatedMember>
18+
</pivot>

0 commit comments

Comments
 (0)