Attaching a Query to a Class

A query can be attached to a class. In this case, the query lies within the scope of instances of the class to which it is attached. For example, suppose a query is attached to the Editor class. This means that the query-checking engine assumes an implicit range over instances of Editor for all undefined variables. 

Before you attach a query to a class, you should make the class queriable. This enables the SLOT-QUERIES slot for the class. A query that has been attached to a class is visible in the SLOT-QUERIES pane of the Class Form for that class. See Making a Class Queriable for more information.

You can attach a query to more than one class.

Note: The same restriction to instances of the Editor class is also enforced by the syntax (defrange ?edit :FRAME Editor). However, attaching a query to a class makes the attachment at the Protégé level, and also makes the query visible at the class.

 Note: By attaching a query to a class, you can make an implicit variable range  definition, that is, you could omit a defrange statement for that variable. This can be used when you want the defrange of the query to apply to multiple classes that are not subclasses of a single class, as otherwise you would have to write the query in the scope of each class.  However, this should be used with caution, because if a query is de-attached from all of its classes, it will lose its implicit range definitions, and will have unbound variables. 

You can attach a query to a class in one of three ways:

At the PAL Queries Tab

To attach a query to a class at the PAL Queries Tab:

  1. Go to the PAL Queries Tab and make sure the query you want to attach to a class is displayed. See Displaying Queries at the PAL Queries Tab for more information.
  2. Select the query by clicking on it. 
  3. Click the Add button at the top right of the Query Attachments pane.


    A Choose class dialog box opens.


  4. Select the class to which you want to attach the query and click OK.
    The selected class is displayed in the Attachments pane. You can view the Class Form for the class by selecting it and then clicking the View button in the Attachments pane. You can also see the query in the Class Form for that class. See Displaying Attached Queries at a Class for more information.

At the Classes Tab

To attach a query to a class at the Classes Tab:

  1. Go to the Classes Tab.
  2. Highlight the class to which you wish to attach the query.
  3. Click the Add button at the upper right of the Class Queries pane in the Class Form. 
    A Select Instances dialog box opens.


  4. Select :PAL-CONSTRAINT on the left.
  5. Select the query(s) you wish to attach to the chosen class on the right.
  6. Click OK.
    The query is attached to the class and appears in the list of queries in the Queries pane in the Class Form.

For information on how to attach a query to a class by creating it at the class, see Creating a Blank Query.


PAL Queries User Interface/Attaching a Query to a Class

Next: Removing a Query from a Class

PAL Table of Contents