Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
The <strong>Caché</strong> Data Population Utility<br />
Property PropertyName As %String(POPSPEC = "MethodToInvoke()");<br />
where PropertyName is the property for which you are generating data and MethodToInvoke<br />
is the method that Populate will call to generate the data.<br />
For example, to specify that a property is the name of a city in the United States, add the<br />
following POPSPEC parameter value to its definition:<br />
Property City As %String(POPSPEC = "USCity()");<br />
When you run the Populate method, it will invoke the USCity method of the %PopulateUtils<br />
class to generate a random city name for this property.<br />
The value of the POPSPEC parameter is a string specifying a method name in one of the<br />
following ways:<br />
• POPSPEC = “Method()” — Populate invokes the method “Method” from the<br />
%PopulateUtils class.<br />
• POPSPEC = “.Method()” — Populate invokes the method “Method” from the current<br />
object instance (the one being populated).<br />
• POPSPEC = “##class(Class).Method()” — Populate invokes the method “Method”<br />
from the “Class” class.<br />
Where applicable, you can include parameter values within the parentheses following the<br />
method name. If you are specifying a string value, use two pairs (““””) of quotation marks<br />
around the value that you specify.<br />
Property Name As %String(POPSPEC = ".MyName(""X"")");<br />
For example, suppose a class definition contains the following code:<br />
Property PName As %String(POPSPEC = "PName:Name(""F"")");<br />
Property Code As %String(POPSPEC = ".MakeCode()");<br />
Property SSN As %String(POPSPEC = "##class(MyApp.Utils).MakeSSN()");<br />
Property Number As %Integer;<br />
Populate generates values for the PName property by calling the method:<br />
Set .. PName = ##class(%PopulateUtils).Name("F")<br />
Populate generates values for the Code property by calling the local class' MakeCode method:<br />
Set ..Code = obj.MakeCode()<br />
where obj is the current object instance being created. (This assumes that you have defined<br />
a MakeCode method in the class.)<br />
164 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>