Skip to content

Commit

Permalink
Merge pull request #32 from intersystems-community/stage
Browse files Browse the repository at this point in the history
Stage
  • Loading branch information
nsolov authored Sep 20, 2020
2 parents 0f379cb + a0e1ed1 commit e8b83c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Module>
<Name>zpm-registry</Name>
<Description>Registry server for ZPM</Description>
<Version>1.0.7</Version>
<Version>1.0.8</Version>
<Packaging>module</Packaging>
<SourcesRoot>src</SourcesRoot>
<Resource Name="ZPM.PKG"/>
Expand Down
43 changes: 36 additions & 7 deletions src/cls/ZPM/Package.cls
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Property owner As %String;

Index Owner On owner;

Property description As %String(MAXLEN = 200, TRUNCATE = 1);
Property description As %String(MAXLEN = 1000, TRUNCATE = 1);

Property keywords As list Of %String;

Expand Down Expand Up @@ -173,6 +173,28 @@ ClassMethod Populate(Path As %String, kill = 0)
}
}

Method UpdateDescriptionFromManifest() As %Status
{
Try {
//save xml to file
Set tFileName = $$$FileTempDir_"/manifest.xml"
Set stream=##class(%Stream.FileCharacter).%New()
$$$ThrowOnError(stream.LinkToFile(tFileName))
$$$ThrowOnError(stream.CopyFrom(..manifest))
$$$ThrowOnError(stream.%Save())
Kill stream
$$$ThrowOnError(##class(%XML.XPATH.Document).CreateFromFile(tFileName, .tDocument))
$$$ThrowOnError(tDocument.EvaluateExpression("/Module/Description", "text()", .tRes))
If (tRes.Count()>0) {
Set ..description = tRes.GetAt(1).Value
}
} Catch ex {
Do ex.Log()
return ex.AsStatus()
}
return $$$OK
}

ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %Boolean = 0) As %Status
{
SET tStream = ##class(%Stream.FileCharacter).%New()
Expand Down Expand Up @@ -205,6 +227,10 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
WRITE !,"Version: ", version
}

SET tSC=tDocument.EvaluateExpression("/Export/Document/Module/Description", "text()", .tRes)
IF $$$ISERR(tSC) Return tSC
SET description = tRes.GetAt(1).Value

SET archive = ##class(%Stream.FileBinary).%New()
SET archiveFileName = ##class(%File).TempFilename("tgz")
SET archive.Filename = archiveFileName
Expand All @@ -220,6 +246,7 @@ ClassMethod LoadPackage(Path As %String, repository As %String = "", silent As %
do ..%DeleteId(name _ "||" _version)
SET package = ..%New()
SET package.name = name
Set package.description = description
Set package.repository = repository
SET package.version = version
SET package.package = archive
Expand Down Expand Up @@ -387,16 +414,18 @@ ClassMethod GetSSLConfiguration(host) As %String
QUIT host
}

Query ListLatest(searchTerm As %String = "") As %SQLQuery(ROWSPEC = "name:%String,repository:%String,version:%String")
Query ListLatest(searchTerm As %String = "") As %SQLQuery(ROWSPEC = "name:%String,description:%String,repository:%String,version:%String")
{
SELECT name, repository, (
SELECT TOP 1 version FROM ZPM.Package p2 WHERE p1.name=p2.name
ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC ) version
SELECT name, repository, version, description
FROM ZPM.Package p1
WHERE :searchTerm IS NULL OR (
WHERE
version= (
SELECT TOP 1 version FROM ZPM.Package p2 WHERE p1.name=p2.name
ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC )
AND (:searchTerm IS NULL OR (
name %MATCHES :searchTerm
OR description %MATCHES :searchTerm
OR keywords %MATCHES :searchTerm
OR keywords %MATCHES :searchTerm)
)
GROUP BY name
ORDER BY name
Expand Down
3 changes: 2 additions & 1 deletion src/cls/ZPM/Registry.cls
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ClassMethod PublishPackage() As %Status

set package = ##class(ZPM.Package).%New()
$$$ThrowOnError(package.%JSONImport(%request.Content))

$$$ThrowOnError(package.UpdateDescriptionFromManifest())
do ##class(ZPM.Package).NameVersionDelete(package.name, package.version)
$$$ThrowOnError(package.%Save())

Expand Down Expand Up @@ -206,6 +206,7 @@ ClassMethod AllPackages() As %Status
While tRS.%Next() {
Set tPkgInfo = {
"name": (tRS.name),
"description": (tRS.Description),
"repository": (tRS.repository),
"versions": [(tRS.version)]
}
Expand Down

0 comments on commit e8b83c8

Please sign in to comment.