3. Using the component browser


CoCompose now features a query-based component browser, capable of understanding standard SQL with an added ATLEAST keyword. This keyword simplifies formulating a kind of qualitative query, which is internally rewritten to use only standard SQL. Here are two examples:

Get every composite in the repository
SELECT DISTINCT *
FROM Library
WHERE type = 'composite-type'

Get all components with an adaptability of at least 'compile-time'
SELECT DISTINCT l.* FROM Library l, Properties p
WHERE l.uri = p.uri AND p.propname = 'quality.adaptability'
AND p.propvalue ATLEAST 'compile-time'

The relational database has the following tables:
Library: uri | name | type
Properties: uri | propname | propvalue
Rankings: propname | propvalue | rank
SavedQueries: name | query

All standard SQL syntax is case-insensitive: e.g. the table LIBRARY is equivalent to Library. The only exception is the ATLEAST keyword, which must be typed exactly as shown. For details on the restrictions on the use of the ATLEAST keyword, please consult the documentation of the Library class.

3.1. Indexing the components

Before you can ask queries about components, the properties of the components must be registered in a database. This 'indexing' process is carried out automatically when the database is empty, but can also be initiated manually by selecting Refresh library from the File menu or typing Ctrl-R. Manual reindexing is necessary when new components are added. The indexer looks for components (models, solution patterns, concepts and composite types) in the ./models and ./repository directories.

3.2. Executing queries

Type the query in the query editor box above the Execute button, then press that button (or type Alt-X). The results will be shown in the list underneath with the following properties:

Pressing the Clear button (Alt-C) will erase the contents of the query editor.

3.3. Managing saved queries

To save the current query for later reuse:

  1. Type the query in the query editor box
  2. Type a name for the query in the combo box at the top, or choose an existing name to overwrite it
  3. Press the left button (blue up arrow)
Your query will now be saved under the chosen name, and the combo box with the list of saved queries will automatically be re-ordered alphabetically.

To copy a previously saved query back into the query editor:

  1. Select the query's name in the combo box at the top
  2. Press the right button (blue down arrow)
The contents of the saved query will be placed in the query editor, replacing any existing text.

To delete a previously saved query:

  1. Select the query's name in the combo box at the top
  2. Press the middle button (red cross)
The selected query will be immediately deleted from disk without warning, so be careful!

3.4. Using query results

Each query result in the list box at the bottom of the browser can be opened in a new window simply by double-clicking on it. A model editor window will pop up showing the component in detail.

Furthermore, the concepts and composites can also be incorporated in new models by selecting the appropriate one in the list box and using the Create repository composite tool in the model editor window.