Basic Model Operations

Table of Contents

Once the models are generated, you can start writing scripts to create instances of these models, manipulate them, and relate instances of different models as defined relations in the models. For example, you may have "Customer" and "Service" models where you have defined an m-to-m relationship between them. In other words, a customer may subscribe to many services through "subscribedTo" relation, and a service may be used by many customers through "subscribedBy" relation.

The basic operations available to the script developers are listed below.

These operations are either static, in other words called on the model itself, or instance specific and called on a specific model class instance. Examples of static methods are "add", "get", and "list" where you are not expected to have an instance in your hand. The purpose of calling one of these static operations is to get reference to one or more instances. Here is an example of a static operation invocation:

def searchResult= Service.search("Gold")

Other methods, such as "update", "remove" are invoked on an instance. Here is an example:

def myService = Service.get(name:"prntserv1945");
def propsMap = myService.asMap();

Notice how an instance is retrieved by making a static call first and then an instance operation (asMap) is invoked on myService.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.