Catalog Modeler

Using Query

 Using CATICatalogQuery,CATICatalogQueryResult
Use Case

Abstract

This use case shows how to filter a chapter to retrieve specific descriptions.


What You Will Learn With This Use Case

Users often need a way of storing and classifying the many objects they have at their disposal, whether they be screws, ball bearings or computer parts. These objects may number tens of thousands, each with its own specific characteristics such as shape, color, size, diameter, length, etc. To facilitate fast and easy retrieval of such objects thus objects avoiding time-wasting redesign Version 5 offers the possibility of creating catalogs. 

The catalog is made up of chapters. The chapters contains keywords to enhance the classification. The goal of this article is to show the usage of two interfaces:

This interface is implemented by the chapter and enables to filter its descriptions.

This interface is implemented by an object which is the result of the query applied to the chapter. On this object you retrieve the filtered descriptions.

Before getting to the use case itself, it is important to already be familiar with the basic notions of Catalog. See the referenced article [1] for a detailed overview.

[Top]

The CAACciCatalogQuery Use Case

CAACciCatalogQuery is a use case of the CAAComponentsCatalogs.edu framework that illustrates ComponentsCatalogsInterfaces framework capabilities.

[Top]

What Does CAACciCatalogQuery Do

The "Creating a Catalog" use case [2] explains the creation of the CAATool catalog. 

Fig.1 The CAATool.catalog Document

This catalog contains the Nuts chapter which has the SideNumber keyword

Fig.2: The Nuts's  Keyword Tab Page

This use case makes a query to filter the descriptions whose the "SideNumber" keyword value is equal to 6. 

[Top]

How to Launch CAACciCatalogQuery

To launch CAACciCatalogQuery , you will need to set up the build time environment, then compile the CAACciCatalogQuery module along with its prerequisites, set up the run time environment, and then execute the use case [3]. 

mkrun -c CAACciCatalogQuery InputPath 

Where:

InputPath : The path of the CAATool.catalog file

You can use those located in CAAComponentsCatalogs.edu/InputData

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Where to Find the CAACciCatalogQuery Code

The CAACciCatalogQuery use case is made of a file, CAACciCatalogQueryMain.cpp, located in the CAACciCatalogQuery.m module of the CAAComponentsCatalogs.edu framework:

depending on operating system you find them :

Windows InstallRootDirectory\CAAComponentsCatalogs.edu\CAACciCatalogQuery.m\
Unix InstallRootDirectory/CAAComponentsCatalogs.edu/CAACciCatalogQuery.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

In the CAACciCatalogQueryMain.cpp file you have two mains steps

  1. Retrieving The Nuts chapter
  2. Filtering The Nuts chapter

[Top]

Retrieving the Nuts chapter

The CAATool catalog contains the Nuts Chapter [Fig 1]. The FindChapter method retrieves it because it is not an external chapter. 

 ...
  CATUnicodeString NutsChapter = "Nuts" ;
  CATICatalogChapter * piNutsChapter = NULL ;
  rc = pICatalogChapterFactory->FindChapter(NutsChapter,piNutsChapter);
 ...

Where pICatalogChapterFactory is the CATICatalogChapterFactory interface pointer on the root container of the CAATool catalog. The use case "Creating a Catalog" [2] explains how to retrieve this pointer.

Filtering on a chapter 

A filtering on a chapter is done thanks to the CATICatalogQuery interface .

 ...
  CATICatalogQuery * piCatalogQueryOnNutsChapter = NULL ;
  rc = piNutsChapter->QueryInterface(IID_CATICatalogQuery,
                                     (void **) &piCatalogQueryOnNutsChapter);
 ...

piCatalogQueryOnNutsChapter is the CATICatalogQuery interface pointer on the Nuts Chapter.

The expression of the filter has a knowledgeware syntax:

 ...
  CATUnicodeString Expression = "(x.SideNumber==6)";
 ...

The other available operators are 

In applying the Query method with the knowledgeware filter (Expression) the result is a QueryResult object. This object implements the CATICatalogQueryResult interface.

Advice: the Query method is not recursive. The research is done on the descriptions of the chapter. It means that if descriptions have links towards sub-chapters, the descriptions of those chapters are not explored.

 ...
  CATICatalogQueryResult * pIQueryResult = NULL;
  rc = piCatalogQueryOnNutsChapter->Query(pIQueryResult,Expression);
 ...

The list of descriptions filtered by the expression is retrieved by the AsAList method.

 ...
  CATListValCATICatalogDescription_var * pListDescription = NULL;
  rc = pIQueryResult->AsAList(pListDescription);

 ...

[Top]


In Short

This use case illustrates the usage of the CATICatalogQuery and CATICatalogQueryResult interface.

[Top]


References

[1] Catalog Overview
[2] Creating a Catalog
[3] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [Jul 2002] Document created
[Top]

Copyright © 2002, Dassault Systèmes. All rights reserved.