Query

A view named Query is available in SysON, allowing users to query the models.

Query View

This view allows to write AQL queries (see AQL documentation for more details) and get the results of the queries written.

This view comes from Sirius Web, the software on which SysON is based upon. It will be improved release after release, with new variables and services, but it is experimental for now.

Three variables are accessible for now, helping to write queries: - self which represents the selected element in the Explorer and/or any open diagram. It always returns one element. - selection which represents the selected elements in the Explorer and/or any open diagram. It always returns a collection of elements (one or several). - editingContext which represent the current project. From this context, you can use the following services:

  • Collection<Object> allContents(): allows to retrieve all contents recursively (documents, and each element of all models) present in your editing context. Please use this service very carefully as it can retrieve thousands elements very easily and may also lead to performance issues.

  • Collection<Object> contents(): allows to retrieve all contents (documents) present in your editing context.

  • Object getObjectById(String id): from its ID, allows to retrieve an object (a document or a SysML v2 model Element) present in your editing context.

The use of this Query view requires knowledge of AQL and also a good knowledge of the SysML v2 language (attributes, references, operations).

Here are some examples of AQL queries applied on a simple project:

  • The following example uses the self variable, corresponding to the Package 1 element (which has been selected in the Explorer view), and asking for its name:

Query View self

The result is visible in the Evaluation result part of the Query view (Package 1).

  • The following example uses the selection variable, corresponding to the part1 and part2 elements (which have been selected in the General View diagram), and asking for the number of selected elements:

Query View selection

The result is visible in the Evaluation result part of the Query view (2).

  • The following example uses the getObjectById service with an ID as parameter, corresponding to the Package 1 element (its ID has been retrieved from the Advanced tab in Details view):

Query View getObjectById

The result is visible in the Evaluation result part of the Query view (Package 1).

  • The following example uses the ownedMember reference from the SysMLv2 language, applied on Package 1 element:

Query View ownedMember

The result is visible in the Evaluation result part of the Query view (part1 and action1). In this case it corresponds to the members of Package 1 that you can also see in the Explorer view on the left side of the screenshot above.