Modeling Services > Rogue Wave Script Integration > Accessing Server Objects from Scripts > Accessing Server Relations
 
Accessing Server Relations
All the relations declared to the server model interpreter are Rogue Wave Script properties of the Rogue Wave Script object. The following methods are defined on the n-ary relation (both direct and inverse relations):
*add(object): Adds this object to the relation.
*remove(object): Removes this object from the relation.
*get(string id): Retrieves an identified object in the relation. This method invokes the member function IlsViewed::getKeyIdentifier to retrieve the object identifier. This method is available only for dynamic relations.
*clear: Empties the server relation.
Example
var d = new Domain("France");
network.domains.add(d);
When you update an inverse relation, the direct relation is assigned.
Example
var d = new Domain("France");
d.network = network;
is equivalent to the previous example.
When you access a unary relation, you access the target of the relation.
Example
var d = new Domain("France");
network.domains.add(d);
writeln("Network name: " + d.network.identifier);
A relation iterator proxy is provided to enable you to iterate on an element of a given n-ary relation.
Example
var i = new IlsServerRelationIterator(network.domains);
while (i.next()) {
writeln("A Domain " + i.current.name);
}
The class IlsServerRelationIterator has the following properties and methods:
*Properties
*eol: Is true when the iterator is at the end of the relation.
*current: Points to the current object in the relation. This property is undefined if eol is true.
*Methods
*next: Returns the next element in the relation. This method modifies the current property.
*reset: Resets the iterator to the beginning of the relation.
*close: Closes the iterator.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.