Adding Projections to a Class
InterSystems® Studio has been deprecatedOpens in a new tab. Beginning with version 2024.2, it is no longer included with installations of InterSystems IRIS®, and it is no longer receiving maintenance updates. An upgrade to InterSystems IRIS 2024.2 or later will remove any Studio installation which is associated with the instance.
The version of InterSystems Studio which was included with InterSystems IRIS 2024.1 is available as a stand-alone component from the WRC Downloads page (https://wrc.intersystems.com/wrc/coDistGen.cspOpens in a new tab). To show only the Studio downloads, type studio in the Name column. Neither upgrades nor new installations of InterSystems IRIS will affect a stand-alone Studio installation.
InterSystems provides the following documentation about Studio 2024.1 for legacy support only. InterSystems recommends that all users develop ObjectScript code using the InterSystems ObjectScript Extension Pack for Visual Studio Code. See Migrate from Studio.
This topic discusses how to add projection definitions in a class definition.
A projection definition instructs the InterSystems IRIS® class compiler to perform specified operations when a class definition is compiled or removed. A projection defines the name of a projection class (derived from the %Projection.AbstractProjection class) that implements methods that are called when either of the following is true:
-
The compilation of a class is complete.
-
A class definition is removed either because it is being deleted or because the class is about to be recompiled.
A class can contain any number of projection definitions. The actions for all of them are invoked when the class is compiled (the order in which they are invoked is not defined).
InterSystems IRIS includes predefined projection classes that generate client code that allows access to a class from Java, MV, and so on.
Class | Description |
---|---|
%Projection.Java | Generates a Java client class to enable access to the class from Java. |
%Projection.Monitor | Registers this class as a routine that works with Log Monitor. Metadata is written to Monitor.Application, Monitor.Alert, Monitor.Item and Monitor.ItemGroup. A new persistent class is created called Monitor.Sample. |
%Projection.MV | Generates an MV class that enables access to the class from MV. |
%Projection.StudioDocument | Registers this class as a routine that works with Studio. |
%Studio.Extension.Projection | Projects the XData 'menu' block to the menu table. |
You can also create your own projection classes and use them from Studio as you would any built-in projection class.
You can add a new projection to a class definition in two ways:
-
Editing the class definition using the Class Editor.
-
Using the New Projection wizard
To add a projection using the Class Editor, position the cursor at a blank line and enter a projection declaration.
Alternatively, you can copy and paste an existing projection declaration and then edit it.
For details, see Projection DefinitionsOpens in a new tab in the Class Definition Reference.
New Projection Wizard
You can invoke the New Projection wizard by selecting Class > Add > Projection. Alternatively right-click in the Class Inspector and select Add > New Projection.
The New Projection wizard displays pages prompting you for information about the new projection. You can click Finish before completing all of the wizard pages; in this case, default values are provided for any information you have not specified.
Name and Description Page
The New Projection wizard prompts you for the following information (you can later modify any of these values):
(required) Name of the new projection. This name must be a valid projection name and must not conflict with the name of a previously defined projection.
(optional) Description of the new projection.
Projection Type Page
The projection type determines what actions happen when your class definition is compiled or removed. You can select what kind of projection you would like to define.
Name of a projection class whose methods are executed when a class definition is compiled or removed.
A set of name-value pairs that control the behavior of the projection class. The list of available parameter names is determined by the selected projection class.
Results of Running the New Projection Wizard
When you finish running the New Projection wizard, the Class Editor window is updated to include the new projection definition. For example:
/// This is a Person class
class MyApp.Person extends %Persistent
{
Property Name As %String;
Projection JavaClient As %Projection.Java;
}
To edit this projection definition, use either the Class Editor or the Class Inspector.