Dev Room > Repository Access API (RAAPI) > Notes on RAAPI

Notes on RAAPI

Iterators

Iterators must always be freed after use. Every repository implementing RAAPI must ensure that iterators are thread-safe: when the repository is modified, the iterator still contains the original list of references. This can be implemented either by always creating a new list for iterable elements or by utilizing the copy-on-write pattern.

Example of using iterators

Iterator it = getIteratorFor...(...);
Reference r = resolveIteratorFirst(it);
while (r != 0) {
    // Process here reference r
    freeReference(r); // not required unless the underlying repository requires this
    r = resolveIteratorNext(it);
}
freeIterator(it);

Advanced associations

We use the term advanced association for n-ary associations, association-classes, and n-ary association-classes. All such associations are created via RAAPI function
createAdvancedAssociation(String name, boolean nAry, boolean associationClass)

An advanced association behaves likes a class (although it might not be a class internally) with n bidirectional associations attached to it. To specify all n association ends, call createAssociation n times, where a reference to the n-ary association has to be passed instead of one of the class references. N-ary association links can be created by means of createObject, and n-ary link ends can be created by calling createLink n times and passing a reference to the n-ary link instead of one of the object references.

Encoding values

There are certain functions expecting data values to be passed to them. To be able to do that in a uniform way, RAAPI expects data values to be passed as strings. The following table explains how values of different data types are converted to strings:

 

Type

How encoded

String

as is (we assume that UNICODE characters ‘INFORMATION SEPARATOR ONE’, ‘INFORMATION SEPARATOR TWO’, ‘INFORMATION SEPARATOR THREE’, ‘INFORMATION SEPARATOR FOUR’, ‘CANCEL’, ‘END OF TEXT’, and ‘NULL’ are not used in String values)

Integer

converted to a string using the decimal notation (with a “-” sign in the beginning for negative integers)

Real

converted to a string using the decimal notation and a dot (“.”) as a decimal point

Boolean

either the string value “true”, or “false” (all letters are small)

void or null (to indicate no value)

a string consisting of a single Unicode character U+0018 (CANCEL); this value is essential to distinguish between null values and empty strings, when calling methods

a collection of some type from above

each collection element is encoded according to the rules above; elements are delimited by the UNICODE character U+001F (INFORMATION SEPARATOR ONE)

 

LyX Document

On Meta-Levels

You may wish to read more on models at http://webappos.org/theory/models.

Linguistic vs. Ontological Metamodelling

Atkinson and Kühne [2, 6, 5] noticed that actually there are two variants of the ``instance of'' relation: ``linguistic instance of'' and ``ontological instance of''. Thus, meta-levels can also be linguistic and ontological. To see the difference between these two types of meta-levels, refer to Figure #. Figure #(a) is an example of UML Four-level Metamodel Hierarchy [#bib_uml_infrastructure]. Although Level M0 (a level of real world objects) lies outside MOF TS, it is depicted for informative purposes. ECore is a possible meta-metamodel for Level M3 (only a small part of it is depicted in Figure #(a)). Level M2 contains a UML-like metamodel described in ECore. For this example it is essential that the M2 Level metamodel is able to describe both classes and objects, see classes Class and Object. Level M1 contains a sample model, which conforms to the UML-like metamodel from Level M2.
All the three levels (M1-M3) are linguistic meta-levels, since the meta-metamodel from Level M3 can be considered a language for specifying metamodels at Level M2, and each metamodel from M2 can be considered a language for specifying models at M1. However, if we look at Level M1 more narrowly, we can see that it can be split into two levels, where UML-style objects occupy one level, and UML-style classes occupy another level (Figure #(b)). The borderline is defined by the ``type'' relation from Level M2. These new levels are called ontological meta-levels. They are denoted O j and O j+1 in Figure #(b), while linguistic meta-levels (M1-M3) have been renamed to L i , L i+1 , and L i+2 . The pivot indices i and j have been introduced here to be independent on any particular absolute numbering. For the purposes of this thesis, only relative arrangement of (both linguistic and ontological) meta-levels will matter.
Figure #(c) adds one more ontological meta-level O j+1 by introducing the MetaClass concept at L i+1 . However, in order to express the six-meta-level example by D. Hofstadter, we must add at least three more meta-classes at L i+1 (in order the total number of ontological meta-levels become six). Figure #(d) shows that instead of introducing meta-class(es), multiple ontological levels can be described by means of the ``type'' relation from Class to Class at L i+1 . This relation can be used as many times as needed, thus, creating a chain of ontological meta-levels as in the example by D. Hofstadter (the ``lowest'' meta-level can be linked to the chain by the ``type'' relation between Object and Class).
In Figure #(d), Class can also be made a subclass of Object at L i+1 (Atkinson and [1] introduce the term ``clabjects'' [from class+object] for such classes). In this case, the ``type'' relation between Object and Class is not needed any more, since its role is played by the ``type'' relation from Class to Class.
In some cases ontological meta-levels can be mixed. In Figure #, a class Person has been added. A person can be linked to a dog by means of the ``owner'' relation defined at Level O j+1 . A person can also be linked to a breed by means of the ``favourite breed'' relation, which crosses levels O j+1 and O j+2 . Having a particular person Peter at O j , we can see that the ``owner'' link lies in the same O j level, while the ``favourite breed'' link crosses two levels O j and O j+1 .
The theory behind the ``instance of'' relation goes even further. , Kaviani, and Hatala show that the (ontological) ``instance of'' relation can be inferred from the two other relations. They suggest to treat each class as consisting of two parts: intentional and extensional [3]. Intentional part specifies common features of objects (e.g., ``has long hair'') and is used for building abstractions; the relation between elements and the intentional part is called ``conformant to''. Extensional part represents a class as a set, to which certain elements (objects) belong; the relation between elements and the extensional part is called ``element of''. For the purposes of this thesis I do not need the ``conformant to'' and ``element of'' relations. Still, I will need both variants (linguistic and ontological) of the ``instance of'' relation.
On the one hand, multiple ontological meta-levels and (usually) the three linguistic meta-levels give power to describe and organize models. On the other hand, it appears that it is difficult for a human to concentrate at more than two meta-levels at a time. While working on a generator for higher order model transformations, where multiple meta-levels are involved, A. Šostaks came to the following conclusion (I call it Šostaks' conjecture):
One of the arguments in favour of this conjecture is as follows. Students learning Java can work with classes and objects easily (two meta-levels are used). Java is an object-oriented language, and it has the Object class, which is a common superclass for all other classes — an easy-to-understand OOP construction. At the same time, Java has the reflection mechanism, which permits considering Java classes as objects. The class named Class has been introduced for that. Actually, it is a meta-class (i.e., it brings an additional meta-level to Java), but represented as an ordinary Java class. At this point students encounter difficulties, since three meta-levels are involved.
Certain RDF/OWL meta-levels can be considered either linguistic, or ontological. In Table table:technical_spaces, RDF can be considered as spanning three linguistic meta-levels: the RDFS level (M3), the RDF vocabulary level (M2), and the RDF individuals level (M1). Still, RDFS permits breaking this level hierarchy, since classes may be individuals at the same time. RDFS also allows meta-levels to be mixed (as in Figure #). The same refers to OWL Full and OWL 2 with RDFS semantics. Thus, we can think of RDF/OWL TS as occupying only two linguistic meta-levels: L 2 containing RDFS/OWL Full definition, and L 1 containing the pool of ontological classes and instances ( L 1 conforms to L 2 ). In this case, L 1 consists of two or more ontological meta-levels, which can be mixed. To deal with different interpretations of meta-levels (whether the given level is linguistic or ontological), I introduce quasi-meta-levels in Section # of this thesis.

Organizing Meta-Levels into Quasi-Meta-Levels

Models are usually organized in multiple meta-levels. To deal with numerous meta-levels in a common way, we organize meta-levels into two groups. The first group will contain the fixed (and, thus, read-only) linguistic meta-metamodel (at Level M3) of some technical space. The second group will contain all other meta-levels that are possible in that technical space. The meta-levels from the second group are not fixed.
I call these two groups the quasi-linguistic meta-level M3 and the quasi-linguistic meta-level M, respectively. The quasi-linguistic level M3 is fixed. In most cases, it will contain the linguistic meta-metamodel of some technical space (hence, the name ``M3''). The level M will contain all other meta-levels that are variable w.r.t. to M3 (either directly, or via other meta-levels). I call these variable levels quasi-ontological meta-levels (in reality, they may be either linguistic, or ontological meta-levels; see below). Figure # illustrates the organization of quasi-meta-levels. Figure # is similar to meta-levels depicted in Figures #(c) and (d) on page elsewhere. The difference is that now we have exactly two quasi-linguistic meta-levels.
Such an organization of quasi-meta-levels has the following benefits:

RAAPI and Meta-Levels

The points below summarize the main characteristics of RAAPI regarding meta-levels.

References

1Colin Atkinson and Thomas Kühne, "Meta-level Independent Modelling", in International Workshop on Model Engineering at 14th European Conference on Object-Oriented Programming (, 2000).
2Atkinson, Colin and Kühne, Thomas, "Model-Driven Development: A Metamodeling Foundation", IEEE Software 20, 5 (2003), pp. 36--41.
3Gašević, Dragan and Kaviani, Nima and Hatala, Marek, "On Metamodeling in Megamodels", in Engels, Gregor and Opdyke, Bill and Schmidt, Douglas and Weil, Frank, ed., Model Driven Engineering Languages and Systems vol. 4735, (Springer Berlin / Heidelberg, 2007), pp. 91-105.
4Kozlovics, Sergejs, "The Orchestra of Multiple Model Repositories", in SOFSEM 2013: Theory and Practice of Computer Science vol. 7741, (Springer Berlin Heidelberg, 2013), pp. 503-514.
5Kühne, Thomas, "Clarifying matters of (meta-) modeling: an author's reply", Software and Systems Modeling 5 (2006), pp. 395-401.
6Kühne, Thomas, "Matters of (Meta-) Modeling", Software and Systems Modeling 5 (2006), pp. 369-385.