ilog.rules.studio.model.query

Interface IlrQueryService

  • All Superinterfaces:
    org.eclipse.emf.ecore.EObject, ilog.rules.brl.bql.parser.IlrBOMConstants, ilog.rules.brl.bql.IlrQueryEnvironment, ilog.rules.brl.bql.IlrQueryParsingService, IlrRuleProjectService, org.eclipse.emf.common.notify.Notifier


    public interface IlrQueryService
    extends IlrRuleProjectService, ilog.rules.brl.bql.IlrQueryEnvironment, ilog.rules.brl.bql.IlrQueryParsingService
    This service is used to run queries written in the BQL language on an rule project.

    Sample use:

     IlrQueryService queryService = (IlrQueryServiceImpl) IlrStudioQueryPlugin.getQueryService(ruleProject);
     IlrQuery myQuery = ...;
     queryService.initQuery(myQuery, null);
     List results = queryService.runQuery();
     
    If a query has actions (for example, "Find all rules such that... Do copy each rule to package pack1"), these actions must be run seperately, once the query has been run and the elements matching it have been returned:
     if (queryService.queryHasActions()) {
       queryService.runQueryActions(results);
     }
     
    • Method Detail

      • initQuery

        void initQuery(IlrRuleProject queryProject,
                     boolean queryIncludeDependencies,
                     java.util.Locale queryLocale,
                     java.lang.String queryText,
                     IlrRuleQueryMatchCollector mc)
                       throws IlrSyntaxError,
                              java.io.IOException
        Initializes a query before it can be run.
        Throws:
        java.io.IOException
        IlrSyntaxError
        Parameters:
        queryProject - the RuleProject on which this query is supposed to run
        queryIncludeDependencies - true if project dependencies must be followed
        queryLocale - the locale of the query
        queryText - the text of the query (e.g. "Find all rules such that...")
        mc - the collector in which the query results will be stored. Passing null means this IlrQueryServiceImpl will be used as collector.
      • runQuery

        java.util.List runQuery()
        Runs the query which the service has been initialized with, and returns the result in a list.

        The list is built by the #IlrRuleQueryMatchCollector object which was used to initialize the service. If the query was on #IlrProjectElement objects, the list will contain #IlrQueryProjectElementWrapper objects.

        See Also:
        IlrQueryProjectElementWrapper
      • queryHasActions

        boolean queryHasActions()
        Returns information on whether the query that has initialized the service has actions or not.

        For example, if the query is of the form "Find all elements such that <condition> Do <actions>" or simply "Find all elements such that <condition>".

      • runQueryActions

        void runQueryActions(java.util.List queryResult)
                             throws java.io.FileNotFoundException
        Runs the query actions (if any) on a list of results.

        The list will typically be the one returned by #runQuery().

        Throws:
        java.io.FileNotFoundException - if a query action such as 'copy to package' or 'move to package' fails because it was specified a package which doesn't exist.
      • getQueryLocale

        java.util.Locale getQueryLocale(ilog.rules.brl.bql.model.IlrQueryElement query)
        Returns the locale of the given query, or a fallback locale if it's null. (null query locales may happen only when reading old queries, current ones are always saved with a locale)

© Copyright IBM Corp. 1987, 2017