Skip to content

Commit

Permalink
Added new visited setting. Set it equal to valid Caché ObjectScript c…
Browse files Browse the repository at this point in the history
…ode and recompile Form.JSON.OBJ class to modify SetVisited method code. SetVisited method allows you to define what object can be output any number of times (by default object can be written once to prevent write loops).
  • Loading branch information
eduard93 committed Sep 11, 2017
1 parent 72e3a7e commit 58d866c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Form/JSON/OBJ.cls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
<Super>%ZEN.Auxiliary.jsonProvider</Super>
<TimeCreated>64099,77101.820492</TimeCreated>

<Method name="SetVisited">
<ClassMethod>1</ClassMethod>
<CodeMode>objectgenerator</CodeMode>
<FormalSpec><![CDATA[&pVisited,pObject:%RegisteredObject,pLevel:%Integer]]></FormalSpec>
<Implementation><![CDATA[
#include %occCPTJSgen
set code = ##class(Form.Settings).getSetting("visited")
if code'="" {
do %code.WriteLine($$$TAB _ code)
} else {
do %code.WriteLine($$$TAB _ "set pVisited(pObject) = """"")
}
]]></Implementation>
</Method>

<Method name="%ObjectToJSON">
<Description><![CDATA[
Write out the contents of object instance <var>pObject</var> to
Expand Down Expand Up @@ -44,7 +59,7 @@ w - Windows-style cr/lf newline<br/>]]></Description>
Quit
}
set pVisited(pObject) = ""
do ..SetVisited(.pVisited, pObject, pLevel)
Set tClass = $classname(pObject)
Expand Down
2 changes: 2 additions & 0 deletions Form/Settings.cls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Set setting "name" value</Description>
if ((value'="utc") && (value'="ignore")) {
set sc = $$$ERROR($$$GeneralError, "Value '" _value _ "' is not a valid timezone setting. Valid values are: ignore, utc")
}
} elseif name = "visited" {
/// TODO add check
} else {
set sc = $$$ERROR($$$GeneralError, "Setting '" _ name _ "' does not exist")
}
Expand Down

0 comments on commit 58d866c

Please sign in to comment.