EMFT Query Overview

The query framework provides the basic infrastructure for specifying and executing queries against a set of EMF-Model elements and their contents. The following are the main classes to be used when formulating query statements:

  1. The IEObjectSource interface provides the search scope elements to be used in a query.
  2. The SELECT class implements a template-function that does the iteration over model elements and applies the search condition on each; it collects the resulting elements into a QueryResultSet object and returns it to the caller.
  3. The FROM class represents the elements to search. It is responsible of providing an appropriate iterator for the elements in the search space.
  4. The WHERE class applies the search conditions over the elements in the search set.
  5. The UPDATE class passes the elements who satisfy the search condition to a caller-supplied modification function. It collects the modified elements into a QueryResultSet object and returns it to the caller.
  6. The QueryResultSet class represents the set of elements returned by a given query.
  7. The EObjectCondition class is the abstract parent of all conditions that deal with model-elements (i.e., EObjects). It incorporates the services of a PruneHandler in order to answers whether or not to prune the element tree at a specific element and thus ignore its children.
  8. The ConditionPolicy class is used to allow the user to decide how to apply a given condition on a collection of a model-element EAttributes or EReferences values. Supports both the: exists (ANY) and for-all (ALL) semantics.
  9. The EObjectStructuralFeatureValueCondition class is the parent class for conditions that are responsible for checking the values held in model-elements' attributes or references. It uses the help of two other condition objects. The first is an EObjectCondition that it used to decide on the validity of context element (a context element is the model element whose attribute we are evaluating) and the other condition is an evaluator Condition that it uses to evaluate the value held in the attribute or the reference and whether or not it matches what the user is looking for.
  10. The framework provides OCL extensions to the EMF Query framework. It defines the interface IOclQueryHelper for performing OCL queries on EMF models. It supports Boolean-valued OCL expressions as query conditions that are used to formulate OCL queries over EMF models. The class OclCondition applies OCL expressions to EObjects. Allows the integration of OCL expressions with other EObjectConditions.

Using the above classes follow the steps described below to create and execute queries.

  1. Create an implementation of the IEObjectSource interface.
  2. Extend the EObjectCondition class to define custom conditions or use one of the pre-defined conditions available as part of the query framework.
  3. Create a statement using the SELECT or UPDATE clauses.
  4. Execute the statement to produce the results.
  5. Check to ensure that the query did not generate any exceptions during its execution

Please refer to the tutorial Query Framework Tutorial and OCL Query Tutorial for reviewing some code samples.


Copyright (c) 2000,2005 IBM Corporation and others. All Rights Reserved.