Working with Queries

The query panel in the top right area of the Composum Console Browser provides another way to navigate trough the repository. You can input SQL2 or XPath queries in the panels input field and execute the query. The found resources are displayed in a table below the input field. With a click on an table item the browser is navigating to the selected resource and their properties can be edited in the properties view.

query panel of the browser

A query can contain up to four placeholder patterns in the query code:

${placeholder_key[.type][.grow]}

For each placeholder an input field is created dynamically in the second line of the input form area (the second line is visible only if placeholders are used).

Each placeholder can have an optional type hint. Currently only 'path' is supported as type hint. A 'path' placeholder input field has an additional path selector button to open the path select dialog.

The 'grow' hint is also optional and is a number which is used as is to define the 'flex-grow' CSS style property of the placeholders input field.

By default the query panel is reusing the resource filter of the browsers tree. This is useful to avoid the case that a resource of the query result can not be selected in the tree if such an item of the result is selected - but this filtering can be switched off.

On the left side of the input field the history of executed queries or the template set panel can be opened. The history contains the last 30 executed queries for direct reuse.

The query templates panel is offering a set of queries to use from the template view. This set ist customizable as described in the following section.

Query Templates
query templates view

The query tool is browsing the repository for configured query template sets. A template set is a node of any primary type with the resource type

composum/nodes/console/query/template/set

wich can be found as a descendant of one of the resource resolvers root paths. All children of such an export set node which are of resource type

composum/nodes/console/query/template

are used as templates for the Composum Console Browser Query panel. You can use the repository to declare your own set of query templates.

The example below illustrates a template set. This is a JSON source view using the direct reference to the the template set shipped with Composum Nodes Console module.

The properties of a template node are:

  • jcr:title (optional; the name is used if not present)
    the title if the collapsible panel in the templates view
  • jcr: description (optional)
    a rich text property to describe the query show as text block in the templates view
  • group (optional)
    a key which is used to build the tabs in the templates view; each group is defining a tab with a list of the templates of this group within; the templates set defines not a group
  • order (optional; is 50 if not present)
    a number to control the ordering of the templates in the tab; a template wit a 'order' attribute lower than another template is placed before the others template
  • sql2 (optional)
    the SQL2 query template code
  • xpath (optional)
    the XPath query template code

Export Search Results (new feature)

There are a lot of uses cases for exporting search results and it's not really possible to find a general format for all thinkable cases. Thus an approach similar to the templates makes it customizable. The query tool is searching for prepared components to generate ('render') the output files and a menu of the possible export formats is generated from the found components. The query export request is forwarded to the selected renderer with a synthetic resource which contains the search results as children.

The query tool is browsing the repository for configured query export configuration sets. Such a set is a node of any primary type with the resource type

composum/nodes/console/query/export/set

wich can be found as a descendant of one of the resource resolvers root paths. All children of such a template set node which are of resource type

composum/nodes/console/query/export

are used as export configuration for the Composum Console Browser Query panel. You can use the repository to declare your own set of query export handlers.

The example below illustrates such an export set. This is a JSON source view using the direct reference to the the export set shipped with Composum Nodes Console module.

The properties of an export configuration node are:

  • jcr:title (optional; the name is used if not present)
    the label of the export menu link
  • jcr: description (optional)
    a short description visible as the title (tooltip) of the menu link
  • group (optional)
    a key which is used to build the groups in the export menu
  • order (optional; is 50 if not present)
    a number to control the ordering of the handlers in the menu
  • exportType (required)
    the resource type of the export handler component; the query request is delegated (forwarded) to this component for the rendering of the export file content
  • selectors (optional)
    a selector string witch is added to the query request and available in the handler
  • filename (optional)
    the filename hint for the browser to store the download