Client-Side Web Memory API
Prerequisites

To use client-side web memory, 2 conditions must be met:

After that, the JavaScript tda.model object becomes available.  Web memory is accessed through this object.

tda.model
Elements by Reference
tda.model[r] is a repository element (
object/association end/attribute/class
) with the given reference represented as a JavaScript object

For each repository element (an object, an association end, an attribute, or a class) a client-side JavaScript object is created. If the element has a reference r in the repository, it can be accessed by index r in tda.model as tda.model[r].

Classes
tda.model.ClassName = function() { creates a new (this) object, registers it within all the maps in tda.model{}, and syncs it with the server } }

For each class from the model repository of the given webAppOS project, a tda.model.ClassName constructor is created. The constructor creates a new repository object of the given class, registers it at the client side, and synchronizes it with the server.

Class Properties

Each class (tda.model.ClassName) has the following properties:

tda.model.ClassName.reference

the repository reference

tda.model.ClassName.className

the class name

tda.model.ClassName.directObjects{}

map: reference->object

tda.model.ClassName.superClasses{}

map: reference->super class

tda.model.ClassName.subClasses{}

map: reference->sub class

tda.model.ClassName.associations{}

map: reference->association

tda.model.ClassName.attributes{}

map: reference->attribute

tda.model.ClassName.getAllObjects()

returns a map: reference->object (the map itself is copied, but objects are not)

tad.model.ClassName.getSubObjects()

returns a map of objects which are instances of subclasses of the given class; no direct object is returned

tda.model.ClassName.getAllAssociations()

returns a map (a copy) of all associations, including the inherited

Object properties

Each object (tda.model[r]) has the following properties:

obj.roleName[]

stores an array of linked objects

obj.linkRoleName(obj2)

links the given object to obj2 and syncs that link

obj.unlinkRoleName(obj2)

deletes the link between the given object and obj2, and syncs that operation

obj.getRoleName()

returns an array of linked objects (the array is copied, the objects are not)

obj.setRoleName(newArr)

unlinks all previously linked objects (by role RoleName) and links the new ones

obj.classes[]

stores an array of direct object types

obj.getClassName()

returns the name of the first object class

obj.isTypeOf(StringOrClass)

returns whether the given object is instance of the given class (the class is specified by the class name or by the JavaScript object tda.model.ClassName)

obj.isKindOf(StringOrClass)

returns whether the given object is instance of the given class or its superclasses (the class is specified by the class name or by the JavaScript object tda.model.ClassName)

Association end properties
assoc.reference

the repository reference

assoc.roleName

the role name for this association end

assoc.sourceClass

the source class as JavaScript object

assoc.targetClass

the target class as JavaScript object

assoc.isComposition

true, if the association end is a composition (linked objects are parts of the given object)

assoc.inverse

the inverse association end

Internals

There are also internal functions used when synced repository actions are received from the server. These actions correspond to Repository Access API (RAAPI), (see http://​webappos​.org​/dev​/raapi).

tda.model.createClass(className, r)
tda.model.createAttributeSetterGetter(obj, name, rAttr)
tda.model.deleteAttributeSetterGetter(obj, name)
tda.model.createAttribute(rClass, name, rType, r)
tda.model.setAttributeValue(rObj, rAttr, val)

tda.model.createAssociationSetterGetter(obj, roleName, rAssoc)
tda.model.deleteAssociationSetterGetter(obj, roleName)
tda.model.createAssociation(rSourceClass, rTargetClass, sourceRoleName, targetRoleName, isComposition, r1, r2)

tda.model.createObject(rClass, r)
...

In addition, there is also the tda.model.checkReference function used to register and create new client-side references.

Client-Side Web Memory Usage Example
var obj = new tda.model.ClassName();
obj.setAttributeName(5);
obj.getAttributeName();
obj.linkRoleName(obj2);
obj.unlinkRoleName(obj2);

var map = tda.model.<ClassName>.getAllObjects();
...