Appendix E Predefined Query Classes
This chapter gives an overview of the query classes which
are predefined in a standard ConceptBase installation.
The names of parameters of the queries are set in typewriter font.
Most of the queries listed here are used by the ConceptBase user
interface CBIva to interaction with the CBserver. A normal user
typically formulates queries herself. In fact, most queries listed below are
very simple and directly representation as query class.
An exception are the functions for computation and counting. They
cannot be expressed by simple query classes but extend the expressiveness
of the system.
E.1 Query classes and generic query classes
These queries can also be used in the constraints of other queries.
E.1.1 Instances and classes
-
ISINSTANCE:
- Checks whether obj is instance of class.
The result is either TRUE or FALSE.
- IS_EXPLICIT_INSTANCE:
- Same as before, but returns TRUE only if
obj is an explicit instance of class.
- find_classes:
- Lists all objects of which objname is an instance.
- find_instances:
- Lists all instances (implicit and explicit) of class.
- find_explicit_instances:
- Same as before, but only explicit instances are returned.
E.1.2 Specializations and generalizations
-
ISSUBCLASS:
- Checks whether sub is subclass of super.
The result is either TRUE or FALSE.
- IS_EXPLICIT_SUBCLASS:
- Same as before, but returns TRUE only if
sub is an explicit subclass of super.
- find_specializations:
- Lists the subclasses of class. If ded
is TRUE, then the result will also include implicit subclasses, if
ded is FALSE only explicit information will be included.
- find_specializations:
- Same as before, but for super classes.
E.1.3 Attributes
-
IS_ATTRIBUTE_OF:
- Returns TRUE if src has an attribute
of the category attrCat which has the value dst.
- IS_EXPLICIT_ATTRIBUTE_OF:
- Same as before, but only for explicit attributes.
- find_all_explicit_attribute_values:
- Lists all attribute values of objname
that are explicitely defined.
- find_iattributes:
- Lists the attributes that go into class.
- find_referring_objects:
- Lists the objects that have an explicit attribute link to class.
- find_referring_objects2:
- Lists the objects that have an explicit attribute link
to objname and for which the attribute link is an instance of cat.
- find_all_referring_objects2:
- Same as before, but including implicit attributes.
- find_attribute_categories:
- Lists all the attribute categories that may be used for
objname. This is a lookup of all attributes of all classes of objname.
- find_incoming_attribute_categories:
- In contrast to the previous query, this query returns
all attribute categories that go into objname (i.e. attribute categories for which
objname can be used as an attribute value).
- find_attribute_values:
- Lists all objects that are attribute values of objname
in the attribute category cat.
- find_explicit_attribute_values:
- Same as before, but only for explicit attributes.
E.1.4 Links between objects
-
find_incoming_links:
- Lists the links that go into objname and are instance
of category. Note that all types of links are returned, including attributes,
instance-of-links and specialization links.
- find_incoming_links_simple:
- Same as before, but without the parameter category.
- find_outgoing_links:
- Lists the links that come out of objname and are instance
of category. Note that all types of links are returned, including attributes,
instance-of-links and specialization links.
- find_outgoing_links_simple:
- Same as before, but without the parameter category.
- get_links2:
- Return the links between src and dst.
- get_links3:
- Return the links between src and dst that are
instance of cat.
E.1.5 Other queries
-
find_object:
- This query just returns the object given as parameter objname,
if it exists. Thus it can be used to check whether objname exists, but
there is a builtin query exists which does the same. The query is
mainly useful in combination with a user-defined answer format (e.g. the Graph Editor
is using this query to retrieve the graphical representation of the object).
- AvailableVersions:
- Lists the instances of Version with
the time since when they are know. This query is used by the user interface
to use a different rollback time (Options → Select Version).
- listModule:
- Lists the the content of a module as Telos frames, see
also section 5.8.
- listModuleReloadable:
- Like listModule but adding a flag to set the module context to the right module context when the frames need to be loaded again into a CBserver.
E.2 Functions
Functions may also be used within other queries. You may define your own functions
(see section 2.5).
E.2.1 Computation and counting
-
COUNT:
- counts the instances of a class, this may be also a query class
- SUM:
- computes the sum of the instances of a class (must be reals or integers)
- AVG:
- computes the average of the instances of a class (must be reals or integers)
- MAX:
- gives the maximum of the instances of a class (wrt. the order of < and >, see section 2.2)
- MIN:
- gives the minimum of the instances of a class (wrt. the order of < and >, see section 2.2)
- COUNT_Attribute:
- counts the attributes in the specified category of an object
- SUM_Attribute:
- computes the sum of the attributes in the specified category of an object (must be reals or integers)
- AVG_Attribute:
- computes the average of the attributes in the specified category of an object (must be reals or integers)
- MAX_Attribute:
- gives the maximum of the attributes in the specified category of an object (wrt. the order of < and >, see section 2.2)
- MIN_Attribute:
- gives the minimum of the attributes in the specified category of an object (wrt. the order of < and >, see section 2.2)
- PLUS:
- computes the sum of two reals or integers
- MINUS:
- computes the difference of two reals or integers
- MULT:
- computes the product of two reals or integers
- DIV:
- computes the quotient of two reals or integers
- IPLUS:
- computes the sum of two integers; result is an integer number
- IMINUS:
- computes the difference of two integers; result is an integer number
- IMULT:
- computes the product of two integers; result is an integer number
- IDIV:
- computes the quotient of two integers and then truncates the quotient to the
largest integer number smaller than or equal to the quotient
ConceptBase realizes the arithmetic functions via its host Prolog system SWI-Prolog.
Integer numbers on Linux are represented
as 64-bit numbers, yielding a maximum range from −264−1
to 264−1. SWI-Prolog supports by default under
Windows and Linux64 arbitrarily long integers.
Real numbers are implemented by SWI-Prolog as 64-bit double precision
floating point numbers. ConceptBase uses 12 decimal digits.
E.2.2 String manipulation functions
-
ConcatenateStrings:
- concatenates two labels, typically strings; the two arguments
can be expressions that are concatenated after their evaluation; the result is a string
in double quotes
- ConcatenateStrings3:
- concatenates three labels; arguments may not be expressions
- ConcatenateStrings4:
- concatenates four labels; arguments may not be expressions
- concat:
- same as ConcatenateStrings
- StringToLabel:
- removes the quotes of a string and returns it as a label (not
an object), useful if labels should be passed as a parameter of a query
- toLabel:
- evaluates the argument and that creates an individual object with
the canonical representation of the argument result; the canonical representation is
an alphanumeric where special characters are replaces by substrings like "C30_"
for special characters
- concatl:
- concatenates the two labels (being the names of any object); the result is
stored as an individual with the concatenated labels; the result is shown as a label, double quotes are
added when the label is not alphanumeric
- concatl4:
- like concatl but with the four arguments (being the names of any object); the result is
stored as an individual with the concatenated labels
- concatl6:
- like concatl but with concatenates the six arguments; the result is
stored as an individual with the concatenated labels
- resultOf:
- The function resultOf(q,x,a) computes the text answer of calling the query q[x]
using the answer format a to create the textual answer. This allows for example to specify complex gproperty labels on the fly (see also section C.5.1)
The result of the function call is stored as an instance of the class HiddenLabel. This hides the label from
being displayed by the listModule query
- toString:
- returns a string for the label of an object, e.g. toString(Class)="Class".
- length:
- returns the number of characters of an object label, excluding the double quotes when the object is
a string, e.g. length("Class")=length(Class)=5
- isLike:
- returns TRUE of the object label (first parameter) matches the wildcard
pattern (second parameter), otherwise FALSE,
e.g. isLike(Class,"Cla*")=TRUE
- valueOf:
- takes as parameter the name of an instance of the class GlobalVariable and returns its value. Currently, we support
the global variable currentPalette. It holds the instance of JavaGraphicalPalette, which is currenty used
by the current CBGraph client connected to the CBserver. Example: valueOf(currentPalette)=TelosPalette.
Example 1: the expression toLabel(concat("*",1+2)) will return
C42_3. The substring "C42_" is the canonical representation (ASCII number)
of "*". The subexpression 1+2 is evaluated to 3.
Example 2: the expression concatl("alfa",concatl(1+1,"beta")) returns alfa2beta.
Note that the arguments "alfa" and "beta" are string constants created as objects on the fly.
You can also have attributes like bill!earns as arguments of concatl. Then, their labels are used
for the concatenation, here "earns". Expressions like concatl("alfa"," **") are also evaluated
but are enclosed in double quotes like "alfa**". Note that all arguments shall be objects.
Strings and integers are automatically recognized by ConceptBase as objects.
E.3 Builtin query classes
These queries must not be used within other queries as they do not return
a list of objects. They may only be used directly from client programs.
-
exists:
- Checks whether objname exists and returns yes or no.
- get_object:
- Returns the frame representation of objname. This
query may be either called with just one parameter (objname) or with
four parameters (objname, dedIn, dedIsa, dedWith).
The ded*-parameters are boolean flags that indicate whether
implicit (deduced) information should also be included in the frame representation.
Note that the order of the parameters hast to be the same as listed above.
- get_object_star:
- Returns the frame representation for all objects with a label
that match the given wildcard expression. Only simple wildcards with a star (*) at the end
are allowed.
- rename:
- Renames an object from oldname to newname.
This is a low-level operation directly on the symbol table that works directly
on the symbol table. It only checks whether newname is not already used as
label for a different object, no other consistency checks are performed.
The parameters have to be given in the order newname, oldname.