User bio
404 bio not found
Member since Mar 11, 2020
Posts:
Replies:
Hello everyone !
I thank the help of all!
with everyone's help, it was possible to create a property with the same behavior as VALUE LIST from the parameters of a class.
below is the test code:
First create the abstraction
Class ing.shared.abstracts.AbstractEnum [ Abstract ] { ClassMethod BuildValueList() As %String { Set valueList = ","_..GetValuesOfParametersString() Return valueList } ClassMethod BuildDisplayList() As %String { Set displayList = ","_..GetParametersString() Return displayList } ClassMethod GetValuesOfParameters() { Set parametersList = ..GetParameters() Set valueList= $lb("") For i=1:1:$LISTLENGTH(parametersList){ Set value = $PARAMETER($CLASSNAME(),$LIST(parametersList,i)) Set $LIST(valueList,i) = value } Return valueList } ClassMethod GetParameters() [ CodeMode = objectgenerator ] { Set parametersClass="" For i=1:1:%class.Parameters.Count(){ Set parametersClass=parametersClass_$LISTBUILD(%class.Parameters.GetAt(i).Name) } Do %code.WriteLine($char(9)_"Return """_parametersClass_"""") } ClassMethod GetParametersString() As %String { Return $listtostring(..GetParameters()) } ClassMethod GetValuesOfParametersString() As %String { Return $listtostring(..GetValuesOfParameters()) } }
Second I created the class with the parameters, containing extension of the abstract class
Class ing.dto.AbstractionItemSectorStatus Extends ing.shared.abstracts.AbstractEnum { Parameter Active = 1; Parameter Inactive = 2; Parameter Production = 3; Parameter Upkeep = 4; }
Create a datatype class referencing a parameter class in your property:
Class ing.dataMap.DataTypeSectorStatusEnum Extends %Integer [ ClassType = datatype ] { Parameter DISPLAYLIST = {##class(ing.dto.AbstractionItemSectorStatus).BuildDisplayList()}; Parameter VALUELIST = {##class(ing.dto.AbstractionItemSectorStatus).BuildValueList()}; }
And finally create a Persistent class:
Class ing.dataMap.TblSector Extends %Persistent { Property Description As %String; Property SectorStatus As DataTypeSectorStatusEnum; }
This architecture can be useful for future code maintenance, creating or changing new abstract classes
Thanks !
Is possible to use the return of the Method to build the VALUELIST ?
Or other property with the same purpose?
Open Exchange applications:
Followers:
Following:
davi massaru has not followed anybody yet.
Global Masters badges:
davi massaru has no Global Masters badges yet.
output of $isobject(..ObjOrigem) is "1"
I tried to do the same test.
```
```
@Julius Kavay, according to $zv , you are running IRIS 2021.1, I'm running IRIS 2022.1