Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The <strong>Caché</strong> Data Population Utility<br />
Property Colors As %String(POPSPEC="ValueList("",Red,Green,Blue"")")<br />
[Collection = list];<br />
Property Kids As Person(POPSPEC=":5")<br />
[Collection = list];<br />
Property Addresses As Address(POPSPEC=":3")<br />
[Collection = list];<br />
Note:<br />
In Studio, each property definition needs to appear on a single line.<br />
For the Colors property, the Populate method generates data using the ValueList method of<br />
the PopulateUtils class, and follows basic POPSPEC syntax. For the Kids property, there is<br />
no specified method, which results in automatically generated references. For the Addresses<br />
property, there is<br />
19.2.3 Populating Arrays<br />
To populate an array, the syntax for setting the value of POPSPEC is:<br />
Property Prop As TypeNm (POPSPEC="MethodNm:MaxNo:KeySpec") [Collection= array];<br />
where Prop is an array of type TypeNm; MethodNm is the populating method for the property;<br />
MaxNospecifies the maximum number of elements in the list; and KeySpec is the populating<br />
method used to generate the key for each element of an array. If MaxNo is not specified, it<br />
defaults to 10. If KeySpec is not specified, it defaults to String.<br />
In the following example, there are arrays of several types of data and different kinds of keys<br />
being generated as well:<br />
Property Tix As %Integer(POPSPEC="Integer():20:Date()") [Collection = array];<br />
Property Reviews As Review(POPSPEC=":3:Date()") [Collection = array];<br />
Property Actors As Actor(POPSPEC=":15:Name()") [Collection = array];<br />
The Attendance property has its data generated using the ValueList method of the PopulateUtils<br />
class; its keys are generated using the Date method of the PopulateUtils class. The Tix property<br />
has no specified method, which results in automatically generated references , and has its<br />
keys also generated using the Date method. The Actors property has no specified method,<br />
which results in automatically generated references, and has its keys generated using the<br />
Name method of the PopulateUtils class.<br />
19.2.4 Custom Populate Actions<br />
To perform custom actions with the Populate method, use the OnPopulate callback method.<br />
166 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>