Skip to content

Caché 2017+ Code Refactoring #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Form/Adaptor.cls.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:46:06">
<Class name="Form.Adaptor">
<Description>
Base form adaptor class, all forms must inherit from this class</Description>
Expand All @@ -8,6 +8,7 @@ Base form adaptor class, all forms must inherit from this class</Description>
<IncludeCode>Form</IncludeCode>
<PropertyClass>Form.Field</PropertyClass>
<Super>Form.Security,Form.Generators</Super>
<TimeChanged>64415,70229.977141</TimeChanged>
<TimeCreated>64090,75147.034342</TimeCreated>
<DependsOn>Form.Info</DependsOn>

Expand Down Expand Up @@ -109,7 +110,7 @@ Get basic information about one object</Description>
<Abstract>1</Abstract>
<ClassMethod>1</ClassMethod>
<FormalSpec>id:%Integer</FormalSpec>
<ReturnType>%Object</ReturnType>
<ReturnType>%DynamicObject</ReturnType>
<Implementation><![CDATA[
set item = {}
set item."_id" = id
Expand All @@ -124,13 +125,13 @@ Get basic information about several form objects.<br>
<var>list</var> - contains objects ids (not oids)]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>list:%ListOfDataTypes</FormalSpec>
<ReturnType>%Array</ReturnType>
<ReturnType>%DynamicArray</ReturnType>
<Implementation><![CDATA[
set objectsList = []
for i=1:1:list.Count() {
set id = list.GetAt(i)
set item = ..getObjectInfo(id)
do objectsList.$push(item)
do objectsList.%Push(item)
}
return objectsList
]]></Implementation>
Expand Down
3 changes: 2 additions & 1 deletion Form/Field.cls.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:47:13">
<Class name="Form.Field">
<Description>
Form field properties</Description>
<Abstract>1</Abstract>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,75443.892382</TimeCreated>

<Parameter name="DISPLAYNAME">
Expand Down
3 changes: 2 additions & 1 deletion Form/File.cls.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:47:29">
<Class name="Form.File">
<Super>%Persistent</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,76829.939948</TimeCreated>

<Property name="name">
Expand Down
5 changes: 3 additions & 2 deletions Form/Generators.cls.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:47:44">
<Class name="Form.Generators">
<Description>
Various generators called on form compilation which does not actually generate any code
Generators that actually generate the code should be placed into Form.Adaptor class</Description>
<Abstract>1</Abstract>
<TimeChanged>64415,70021.635618</TimeChanged>
<TimeCreated>64110,50058.313465</TimeCreated>

<Method name="onGenerateMetadata">
<Description>
End form callback method</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[&metadata:%Object]]></FormalSpec>
<FormalSpec><![CDATA[&metadata:%DynamicObject]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[ Return $$$OK
]]></Implementation>
Expand Down
23 changes: 12 additions & 11 deletions Form/Info.cls.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:47:54">
<Class name="Form.Info">
<Abstract>1</Abstract>
<IncludeCode>Form</IncludeCode>
<TimeChanged>64415,70317.777266</TimeChanged>
<TimeCreated>64090,75344.051371</TimeCreated>

<Method name="getFormsList">
<Description>
Get all forms list
w ##class(Form.Info).getFormsList().$toJSONFormat()</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Array</ReturnType>
<ReturnType>%DynamicArray</ReturnType>
<Implementation><![CDATA[
#dim sc As %Status = $$$OK
set forms = []
Expand All @@ -25,7 +26,7 @@ w ##class(Form.Info).getFormsList().$toJSONFormat()</Description>
CONTINUE:'..formExists(className)
set formName = $parameter(className, $$$formNameParam)
set formObj = {"name": (formName), "class": (className)}
do forms.$push(formObj)
do forms.%Push(formObj)
}

quit forms
Expand All @@ -37,12 +38,12 @@ w ##class(Form.Info).getFormsList().$toJSONFormat()</Description>
Get all forms metadata
w ##class(Form.Info).getFormsMetadata().$toJSONFormat()</Description>
<ClassMethod>1</ClassMethod>
<ReturnType>%Object</ReturnType>
<ReturnType>%DynamicObject</ReturnType>
<Implementation><![CDATA[
set formsList = ..getFormsList()
set metadata = {}
for i = 0:1:formsList.$size()-1 {
set form = formsList.$get(i)
for i = 0:1:formsList.%Size()-1 {
set form = formsList.%Get(i)
do metadata.%DispatchSetProperty(form.class, ..getFormMetadata(form.class))
}
quit metadata
Expand Down Expand Up @@ -90,7 +91,7 @@ For results see:
<example>w ##class(Form.Info).getFormMetadata("Form.Test.Simple").$toJSONFormat()</example>]]></Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>className:%String=""</FormalSpec>
<ReturnType>%Object</ReturnType>
<ReturnType>%DynamicObject</ReturnType>
<Implementation><![CDATA[
#dim sc As %Status = $$$OK
set formName = $parameter(className, $$$formNameParam)
Expand All @@ -109,17 +110,17 @@ For results see:
set displayName = ##class(Form.Property).getPropertyParam(className, property, $$$propDisplayNameParam)
if ((internal '= $$$YES) && (displayName'="")) {
set propertyMetaData = ##class(Form.Property).propertyToMetadata(className, property)
do metadata.fields.$set($$$comMemberKeyGet(className, $$$cCLASSproperty, property, $$$cPROPsequencenumber), propertyMetaData)
do metadata.fields.%Set($$$comMemberKeyGet(className, $$$cCLASSproperty, property, $$$cPROPsequencenumber), propertyMetaData)
}
set property=$$$comMemberNext(className, $$$cCLASSproperty, property)
}

/// we're moving from the end of array to the beginning
/// so we can delete null elements without affecting
/// the position of elements we're yet to check
for i = metadata.fields.$size()-1:-1:0 {
if metadata.fields.$getTypeOf(i)="unassigned" {
do metadata.fields.$remove(i)
for i = metadata.fields.%Size()-1:-1:0 {
if metadata.fields.%GetTypeOf(i)="unassigned" {
do metadata.fields.%Remove(i)
}
}

Expand Down
3 changes: 2 additions & 1 deletion Form/JSON/OBJ.cls.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:48:39">
<Class name="Form.JSON.OBJ">
<Description>
Преобразует объект класса Cache в JSON.
Изменения ищутся по слову FORMS</Description>
<Super>%ZEN.Auxiliary.jsonProvider</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64099,77101.820492</TimeCreated>

<Method name="%ObjectToJSON">
Expand Down
13 changes: 7 additions & 6 deletions Form/JSON/SQL.cls.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:03">
<Class name="Form.JSON.SQL">
<IncludeCode>Form</IncludeCode>
<Super>%ZEN.Auxiliary.altJSONSQLProvider</Super>
<TimeChanged>64415,70816.9136</TimeChanged>
<TimeCreated>64091,68899.667254</TimeCreated>

<Method name="WriteJSONFromSQL">
Expand Down Expand Up @@ -282,13 +283,13 @@ Draw JSON output.</Description>
}
Set ..sql = tOrigSQL

Set aet = ##class(%Object).$fromJSON("{"""_..arrayName_""":[]}")
Set aet = ##class(%Object).%FromJSON("{"""_..arrayName_""":[]}")

// FORMS - debug
Set:$$$debug aet.sql = tOrigSQL
// END - FORMS - debug

Set arrayNode = aet.$get(..arrayName)
Set arrayNode = aet.%Get(..arrayName)

// FORMS - pagination
Set tStartRow = ..pageSize * (..currPage - 1)
Expand All @@ -310,7 +311,7 @@ Draw JSON output.</Description>
For c = 1:1:tCols {
Set tVal = tRS.%GetData(c)
Set tOutVal = ##class(Form.Util.Converter).logicalToJSON($Get(tColInfo(c,"type")), tVal)
Do node.$set($Get(tColInfo(c,"name")), tOutVal)
Do node.%Set($Get(tColInfo(c,"name")), tOutVal)

/*If ($IsValidNum(tVal)) {
Do node.$set($Get(tColInfo(c,"name")),$Num(tVal),"number")
Expand All @@ -319,15 +320,15 @@ Draw JSON output.</Description>
Do node.$set($Get(tColInfo(c,"name")),tVal)
}*/
}
Do arrayNode.$push(node)
Do arrayNode.%Push(node)
}

// FORMS - results count
While tRS.%Next() {}
Set aet.total=tRS.%ROWCOUNT
// END - FORMS - results count

Write aet.$toJSON()
Write aet.%ToJSON()
}
Catch(ex) {
Write "null"
Expand Down
5 changes: 3 additions & 2 deletions Form/Property.cls.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:48:04">
<Class name="Form.Property">
<Description>
Methods for form field === class property</Description>
<Abstract>1</Abstract>
<IncludeCode>Form</IncludeCode>
<TimeChanged>64415,70687.774584</TimeChanged>
<TimeCreated>64090,75759.538379</TimeCreated>

<Method name="propertyToMetadata">
Expand All @@ -13,7 +14,7 @@ Get metadata for one field of a form. Equal to propertyToMetadata method,
but uses direct global references instead of object access</Description>
<ClassMethod>1</ClassMethod>
<FormalSpec>className:%String="",name=""</FormalSpec>
<ReturnType>%Object</ReturnType>
<ReturnType>%DynamicObject</ReturnType>
<Implementation><![CDATA[
set metadata = {}
set metadata.name = name
Expand Down
3 changes: 2 additions & 1 deletion Form/REST/Abstract.cls.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:18">
<Class name="Form.REST.Abstract">
<Description>
Абстрактный класс, реализующий техническую обработку входящего запроса.</Description>
<IncludeCode>%occErrors,%ZEN.Utils,Form</IncludeCode>
<Super>%CSP.REST</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,76470.397537</TimeCreated>

<Parameter name="CONTENTTYPE">
Expand Down
3 changes: 2 additions & 1 deletion Form/REST/Field.cls.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:28">
<Class name="Form.REST.Field">
<Description>
Брокер работы с полями форм</Description>
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,79242.449407</TimeCreated>

<XData name="UrlMap">
Expand Down
3 changes: 2 additions & 1 deletion Form/REST/File.cls.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:37">
<Class name="Form.REST.File">
<Description>
This broker does file-related work.
All file properies are assumed to be of Form.File class</Description>
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64091,74902.525566</TimeCreated>

<XData name="UrlMap">
Expand Down
9 changes: 5 additions & 4 deletions Form/REST/Form.cls.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:44">
<Class name="Form.REST.Form">
<Description>
Класс работы с формами и их содержимым</Description>
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,70738.823095</TimeChanged>
<TimeCreated>64090,79002.958751</TimeCreated>

<XData name="UrlMap">
Expand All @@ -29,7 +30,7 @@ Get available forms list as a JSON array</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set forms = ##class(Form.Info).getFormsList()
write forms.$toJSON()
write forms.%ToJSON()
return $$$OK
]]></Implementation>
</Method>
Expand All @@ -41,7 +42,7 @@ Get available forms metadata as JSON object</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set metadata = ##class(Form.Info).getFormsMetadata()
write metadata.$toJSON()
write metadata.%ToJSON()
return $$$OK
]]></Implementation>
</Method>
Expand All @@ -54,7 +55,7 @@ Get form metainformation by name</Description>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set metadata = ##class(Form.Info).getFormMetadata(form)
write metadata.$toJSON()
write metadata.%ToJSON()
return $$$OK
]]></Implementation>
</Method>
Expand Down
5 changes: 3 additions & 2 deletions Form/REST/Main.cls.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:49:53">
<Class name="Form.REST.Main">
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,70755.832506</TimeChanged>
<TimeCreated>64090,76630.913942</TimeCreated>

<XData name="UrlMap">
Expand Down Expand Up @@ -47,7 +48,7 @@
<Implementation><![CDATA[
set info = {}
set info.languages = ##class(Form.Util.Translate).getLanguages()
write info.$toJSON()
write info.%ToJSON()
quit $$$OK
]]></Implementation>
</Method>
Expand Down
3 changes: 2 additions & 1 deletion Form/REST/Object.cls.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:50:04">
<Class name="Form.REST.Object">
<Description>
Брокер работы с индивидуальными объектами</Description>
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,79332.572705</TimeCreated>

<XData name="UrlMap">
Expand Down
3 changes: 2 additions & 1 deletion Form/REST/Objects.cls.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:50:13">
<Class name="Form.REST.Objects">
<Description>
Broker class to work with queries</Description>
<Super>Form.REST.Abstract</Super>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64090,79332.572705</TimeCreated>

<Parameter name="ALL">
Expand Down
3 changes: 2 additions & 1 deletion Form/Security.cls.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:48:16">
<Class name="Form.Security">
<Abstract>1</Abstract>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64099,78607.760597</TimeCreated>

<Parameter name="OBJPERMISSIONS">
Expand Down
3 changes: 2 additions & 1 deletion Form/Settings.cls.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25">
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2017.2 (Build 543U)" ts="2017-05-12 19:48:26">
<Class name="Form.Settings">
<Description>
Get and set settings</Description>
<Abstract>1</Abstract>
<IncludeCode>Form</IncludeCode>
<TimeChanged>64415,69633</TimeChanged>
<TimeCreated>64110,52980.392815</TimeCreated>

<Method name="getSetting">
Expand Down
Loading