Query

The Query Tool

       Video tutorial on the query function

The query function is found from the Workbench under the Tools Menu. Use the Sidebar to select a desired Data Type to search for in your Query. The Query function lets you formulate a search query by writing criteria connected through the logical operators AND and OR. This way of writing Queries is easy to overview and to edit since the entire query is visible and editable on one page. To specify a query, first select the initial data type that you are looking for and then fill out a criterion. The AND operator is chosen per default. I’ll come back to the OR operator in a moment.Say that I want my query to find all Associations that are a kind of Business Improvement Initiative. When I set the data type to Association a criterion with the definition is a kind of is automatically added, since an association always require a definition. If you know that your definition doesn’t have any sub classes it’s more efficient to change the criterion to equals so that the system won’t make unnecessary searches. And when you expand and scroll through this combo box, the information will load faster if you narrow it down with a by writing part of the name of the definition that you are looking for. This function uses contains to find definitions, so you can write any part of the name to find it.            

Adding Criteria

Click any of two Operators AND or OR  to add a criterion. AND is selected by default, which is indicated by the arrow. When adding an OR criterion, the OR operator button needs to be pressed first to create a subquery within which an OR criterion can be added.

When adding a criterion you have five paths to choose from the menu

Attributes

 

The Algorithm that decides what Attributes to display works in the following way:

Simple Search Query

All attributes (regardless of existing actual instances of the definition) that are defined on given definition(s) and super classes in the search query. Only the class attributes is displayed if no definition or is a kind of is given. Example: Definition = A, Definition = A AND Definition = B (etc), Is a kind of = A, Is a kind of = A AND Is a kind of = B (etc), Definition = A AND Is a kind of = B (etc)

Complex Search Query

Only attributes that are defined on given definition(s) and super classes in the search query that actually have instances. Only the class attributes is displayed if no definition or is a kind of is given.

Example: Definition = A OR Definition = B (etc), Definition = A OR Is a kind of = B (etc)

References

 

Relations

The Algorithm that decides what Relations to display works in the following way:

Simple Search Query

All relations (regardless of existing instances to the relation) that are defined on given definition(s) and super classes in the search query.

Complex Search Query

Only relations that are defined on given definition(s) and super classes in the search query that actually have instances. Only the class attributes is displayed if no definition or is a kind of is given.

Parameters in Queries


       Video tutorial on parameters in queries

Parameters are used to set up query statements that should be configurable. This is useful for statements that continuously change, or that are to be configurable outside of the Knowledge Set Builder, like the API.

A good example is to create a parameter with the variable @NOW, which returns always returns the current date and time, this allows us to set up queries that always use the current date, rather than a fixed one in a query. Another example is to let users change the content of a column by setting another defining unit over the API. We can use then use the knowledge set as a foundation for interactive, custom built solutions for the end users.

 

Add and edit parameters through the input field in a query

When creating a parameter we are required to make the following entries

Parameter The name of the parameter
Data Type The class of the parameter. Notice that we need a class that maches the statement. If a parameter is used for an attribute with the given class Integer, The parameter must be of the same class.
Default Expression The expression that is executed when the query is run.

 

Applicable parameters (those who matches the class of the statement) is available for selection from the menu within a query.

 

Examples of use

1. Use a Parameter to return the Initiatives that launched less than a month ago

This Query contains Business Improvement Initiatives and their start and end dates. By adding a statement for the From Date attribute in Time Period  we are able to say that:

The From Date is larger than…

and then add a parameter that returns the date one month ago from today.

 

The Query will now always return Initiatives where the From Date is larger than A month ago, no matter when it is being run.

Query Results

Press Run to return the units that matches the given Query. The table below returns the query results.

You can right click units in a query result to interact with them.

 

 

 

Right-Click Menu

Open Opens Unit for viewing and editing of the units attributes
Open in new tab Opens Unit in new browser tab
Open in Model Builder Opens Unit in Model Builder
Copy ID Copies the ID of the Unit
Create copy Opens a Copy of the selected Unit with the given name Copy of [Unit Name]. Notice that the copy is not saved to the database until you press
Bookmark [Unit Type] Adds the selected Unit to the Library

View and Edit Units

From the returned Query results you are able to open any unit to edit or view its usages, by double-clicking or right-clicking and choosing open/open in a new tab.

You are able to edit units definitions, relations and attributes (depending on the unit type) by making changes to the available entries for the unit.

Usages

Open Used X times to see where a unit is being used. This functionality allows you to effectively determine where changes made to the unit will apply.

Click any unit to open it in a new tab.

 

Usages analyze the following

Relations,
Subclasses and Implementing definitions,
Value references,
Query constants,
Value Set constants,
Applications constants, used in queries and specification of links between boxes,
Calls in methods (only methods)
Constant in OBJECT primitive ( all types).

Usages DOES NOT analyze
Expressions (Application variables, calculated columns, presentations, etc)
Instances
Constants in methods (only OBJECT primitive as stated above)

 

 

Suggest Edit