<commit_before><?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="CPM.Registry.Package">
<IncludeCode>CPM.LIB</IncludeCode>
<Super>%Persistent,CPM.IPackage</Super>
<TimeCreated>63577,86035.524325</TimeCreated>

<Index name="byName">
<IdKey>1</IdKey>
<Properties>name</Properties>
</Index>

<Property name="Modified">
<Type>%TimeStamp</Type>
</Property>

<Index name="byKeywords">
<Properties>keywords(ELEMENTS)</Properties>
</Index>

<Index name="byMaintainers">
<Properties>maintainers(ELEMENTS)</Properties>
</Index>

<Method name="%OnNew">
<FormalSpec>initvalue:CPM.IPackage</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    if $data(initvalue) && $isobject(initvalue) {
        set ..author = initvalue.author
        set ..name = initvalue.name
        set ..path  = initvalue.path
        set ..version  = initvalue.version
        set ..license  = initvalue.license
        set ..description  = initvalue.description

        set ..dependencies = initvalue.dependencies
        set ..keywords = initvalue.keywords
        set ..maintainers = initvalue.maintainers
        set ..items = initvalue.items
    }
    quit $$$OK
]]></Implementation>
</Method>

<Method name="%OnBeforeSave">
<FormalSpec>insert:%Boolean</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    // FIXME: bad, bad me - we should not modify state of the object upon saving!
    set ..Modified = $ZDT($ZTS,3,,3)

    quit $$$OK
]]></Implementation>
</Method>

<Method name="DUPE%OnBeforeSave">
<FormalSpec>insert:%Boolean</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    // FIXME: bad, bad me - we should not modify state of the object upon saving!
    set ..Modified = $ZDT($ZTS,3,,3)

    quit $$$OK
]]></Implementation>
</Method>

<Method name="CreateOrOpenId">
<ClassMethod>1</ClassMethod>
<FormalSpec>id:%String</FormalSpec>
<ReturnType>CPM.Registry.Package</ReturnType>
<Implementation><![CDATA[
    if ..%ExistsId(id) {
        set o = ..%OpenId(id)
    } else {
        set o = ..%New()
        set o.Name = id
    }
    quit o
]]></Implementation>
</Method>

<Method name="Load">
<ClassMethod>1</ClassMethod>
<FormalSpec>Package,Value:%ZEN.proxyObject</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    #dim package As CPM.Registry.Package = ..%OpenId(Package)
    set:'$isobject(package) package=..%New()
    set package.name        = Package
    set package.description = Value.description
    
    do package.Keywords.Clear()
    for i=1:1:Value.keywords.Size {
        do package.keywords.Insert(Value.keywords.GetAt(i))
    }
    do package.maintainers.Clear()
    if Value.maintainers.%IsA("%ListOfObjects") {
        for i=1:1:Value.maintainers.Size {
            do package.maintainers.Insert(Value.maintainers.GetAt(i).name)
        }
    }
    set package.author   = $select($isobject(Value.author):Value.author.name, 1:"")
    set package.modified = $tr(Value.time.modified,"TZ"," ")
    do Value.versions.%CopyToArray(.versions)
    set tVersion=""
    for {
        set tVersion = $order(versions(tVersion),1,latest)
        quit:tVersion=""
        continue:latest'="latest"
        set package.version = tVersion
    }
    quit package.%Save()
]]></Implementation>
</Method>

<Method name="Export">
<Description>
common method for exporting package to the staging area
regardless of a format it should generate package.json pointing to the 
appropriate container</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    #dim DirectoryName As %String = $$$CpmConfig.tempdir
    #dim fileName As %String = ##class(%Library.File).NormalizeFilename("package.json",DirectoryName)
    // 1. export/generate metainfo
    do ..ExportJSON(fileName, $this) // FIXME - attribute case
    // 2. export container
    // FIXME - at the moment exporting only using XML
    set fileName = ##class(%Library.File).NormalizeFilename("sample.xml",DirectoryName)
    #dim listItems = $lts(..Items.Serialize(),",")
    do $system.OBJ.Export(listItems,fileName)
]]></Implementation>
</Method>

<Method name="ExportJSON">
<Description>
FIXME - at the moment we output attributes at the same case as properties written
but we need them in low case eventually</Description>
<Internal>1</Internal>
<ClassMethod>1</ClassMethod>
<FormalSpec>FileName:%String,o:%Library.RegisteredObject</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    set io = $io
    set file = FileName
    open file:"WNS":0 else  quit $$$ERROR($$$FileCanNotOpen,file)
    use file
    if $isobject(o) {
        Do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(o)
    }
    use io
    close file

    quit $$$OK
]]></Implementation>
</Method>

<Method name="%DispatchSetProperty">
<Description>
is used to set the value of an unknown property.</Description>
<FormalSpec>Property:%String,Val</FormalSpec>
<ServerOnly>1</ServerOnly>
</Method>

<Method name="%DispatchGetProperty">
<Description>
Is used to get the value of an unknown property.</Description>
<FormalSpec>Property:%String</FormalSpec>
<ServerOnly>1</ServerOnly>
<Implementation><![CDATA[   quit ""
]]></Implementation>
</Method>

<Query name="Search">
<Type>%SQLQuery</Type>
<FormalSpec>Value:%String</FormalSpec>
<SqlProc>1</SqlProc>
<SqlQuery>SELECT id from (
    SELECT id FROM package where UPPER(name) %INLIST UPPER(:Value)
    union all
    SELECT id FROM package where FOR SOME %ELEMENT(keywords) (%VALUE %INLIST(:Value))
    union all
    SELECT id FROM package where description %CONTAINSTERM(:Value)
    union all
    SELECT id FROM package where FOR SOME %ELEMENT(maintainers) (%VALUE %INLIST(:Value))
) GROUP BY id</SqlQuery>
</Query>
</Class>
</Export>
<commit_msg>Removing %OnBeforeSave duplicate method. [Introduced by recent merge of branches]<commit_after><?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Class name="CPM.Registry.Package">
<IncludeCode>CPM.LIB</IncludeCode>
<Super>%Persistent,CPM.IPackage</Super>
<TimeCreated>63577,86035.524325</TimeCreated>

<Index name="byName">
<IdKey>1</IdKey>
<Properties>name</Properties>
</Index>

<Property name="Modified">
<Type>%TimeStamp</Type>
</Property>

<Index name="byKeywords">
<Properties>keywords(ELEMENTS)</Properties>
</Index>

<Index name="byMaintainers">
<Properties>maintainers(ELEMENTS)</Properties>
</Index>

<Method name="%OnNew">
<FormalSpec>initvalue:CPM.IPackage</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    if $data(initvalue) && $isobject(initvalue) {
        set ..author = initvalue.author
        set ..name = initvalue.name
        set ..path  = initvalue.path
        set ..version  = initvalue.version
        set ..license  = initvalue.license
        set ..description  = initvalue.description

        set ..dependencies = initvalue.dependencies
        set ..keywords = initvalue.keywords
        set ..maintainers = initvalue.maintainers
        set ..items = initvalue.items
    }
    quit $$$OK
]]></Implementation>
</Method>

<Method name="%OnBeforeSave">
<FormalSpec>insert:%Boolean</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    // FIXME: bad, bad me - we should not modify state of the object upon saving!
    set ..Modified = $ZDT($ZTS,3,,3)

    quit $$$OK
]]></Implementation>
</Method>

<Method name="CreateOrOpenId">
<ClassMethod>1</ClassMethod>
<FormalSpec>id:%String</FormalSpec>
<ReturnType>CPM.Registry.Package</ReturnType>
<Implementation><![CDATA[
    if ..%ExistsId(id) {
        set o = ..%OpenId(id)
    } else {
        set o = ..%New()
        set o.Name = id
    }
    quit o
]]></Implementation>
</Method>

<Method name="Load">
<ClassMethod>1</ClassMethod>
<FormalSpec>Package,Value:%ZEN.proxyObject</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    #dim package As CPM.Registry.Package = ..%OpenId(Package)
    set:'$isobject(package) package=..%New()
    set package.name        = Package
    set package.description = Value.description
    
    do package.Keywords.Clear()
    for i=1:1:Value.keywords.Size {
        do package.keywords.Insert(Value.keywords.GetAt(i))
    }
    do package.maintainers.Clear()
    if Value.maintainers.%IsA("%ListOfObjects") {
        for i=1:1:Value.maintainers.Size {
            do package.maintainers.Insert(Value.maintainers.GetAt(i).name)
        }
    }
    set package.author   = $select($isobject(Value.author):Value.author.name, 1:"")
    set package.modified = $tr(Value.time.modified,"TZ"," ")
    do Value.versions.%CopyToArray(.versions)
    set tVersion=""
    for {
        set tVersion = $order(versions(tVersion),1,latest)
        quit:tVersion=""
        continue:latest'="latest"
        set package.version = tVersion
    }
    quit package.%Save()
]]></Implementation>
</Method>

<Method name="Export">
<Description>
common method for exporting package to the staging area
regardless of a format it should generate package.json pointing to the 
appropriate container</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    #dim DirectoryName As %String = $$$CpmConfig.tempdir
    #dim fileName As %String = ##class(%Library.File).NormalizeFilename("package.json",DirectoryName)
    // 1. export/generate metainfo
    do ..ExportJSON(fileName, $this) // FIXME - attribute case
    // 2. export container
    // FIXME - at the moment exporting only using XML
    set fileName = ##class(%Library.File).NormalizeFilename("sample.xml",DirectoryName)
    #dim listItems = $lts(..Items.Serialize(),",")
    do $system.OBJ.Export(listItems,fileName)
]]></Implementation>
</Method>

<Method name="ExportJSON">
<Description>
FIXME - at the moment we output attributes at the same case as properties written
but we need them in low case eventually</Description>
<Internal>1</Internal>
<ClassMethod>1</ClassMethod>
<FormalSpec>FileName:%String,o:%Library.RegisteredObject</FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
    set io = $io
    set file = FileName
    open file:"WNS":0 else  quit $$$ERROR($$$FileCanNotOpen,file)
    use file
    if $isobject(o) {
        Do ##class(%ZEN.Auxiliary.jsonProvider).%ObjectToJSON(o)
    }
    use io
    close file

    quit $$$OK
]]></Implementation>
</Method>

<Method name="%DispatchSetProperty">
<Description>
is used to set the value of an unknown property.</Description>
<FormalSpec>Property:%String,Val</FormalSpec>
<ServerOnly>1</ServerOnly>
</Method>

<Method name="%DispatchGetProperty">
<Description>
Is used to get the value of an unknown property.</Description>
<FormalSpec>Property:%String</FormalSpec>
<ServerOnly>1</ServerOnly>
<Implementation><![CDATA[   quit ""
]]></Implementation>
</Method>

<Query name="Search">
<Type>%SQLQuery</Type>
<FormalSpec>Value:%String</FormalSpec>
<SqlProc>1</SqlProc>
<SqlQuery>SELECT id from (
    SELECT id FROM package where UPPER(name) %INLIST UPPER(:Value)
    union all
    SELECT id FROM package where FOR SOME %ELEMENT(keywords) (%VALUE %INLIST(:Value))
    union all
    SELECT id FROM package where description %CONTAINSTERM(:Value)
    union all
    SELECT id FROM package where FOR SOME %ELEMENT(maintainers) (%VALUE %INLIST(:Value))
) GROUP BY id</SqlQuery>
</Query>

<Storage name="Default">
<Type>%Library.CacheStorage</Type>
<DataLocation>^CPM.Registry.PackageD</DataLocation>
<DefaultData>PackageDefaultData</DefaultData>
<IdLocation>^CPM.Registry.PackageD</IdLocation>
<IndexLocation>^CPM.Registry.PackageI</IndexLocation>
<StreamLocation>^CPM.Registry.PackageS</StreamLocation>
<Data name="PackageDefaultData">
<Value name="1">
<Value>%%CLASSNAME</Value>
</Value>
<Value name="2">
<Value>Modified</Value>
</Value>
<Value name="3">
<Value>path</Value>
</Value>
<Value name="4">
<Value>version</Value>
</Value>
<Value name="5">
<Value>license</Value>
</Value>
<Value name="6">
<Value>keywords</Value>
</Value>
<Value name="7">
<Value>description</Value>
</Value>
<Value name="8">
<Value>dependencies</Value>
</Value>
<Value name="9">
<Value>items</Value>
</Value>
<Value name="10">
<Value>maintainers</Value>
</Value>
<Value name="11">
<Value>author</Value>
</Value>
</Data>
</Storage>
</Class>
</Export>

{'fraction_non_alphanumeric': 0.15637254901960784, 'fraction_numerical': 0.007761437908496732, 'mean_word_length': 4.394887615689731, 'pattern_counts': {'":': 2, '<': 316, '<?xml version=': 2, '>': 316, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5740806', 'n_tokens_mistral': 3954, 'n_tokens_neox': 3863, 'n_words': 865}