Built-in functions

Built-in functions provide a convenient way to access properties of both the source files and the migrate objects, potential Rational® Synergy objects.

Not all migrate sources support all these properties. For example, when performing a full migrate from a plain file system, attributes such as release, state, or comment are not defined.

If a mapping rule attempts to access an undefined property, a special undefined value is returned. All operations on undefined values return an undefined value, except for the undefined function, which returns TRUE. The Boolean value of an undefined value is FALSE, so if a condition results in an undefined value, the corresponding action is not performed.

Table 1. Function and return type
Function Return type Description
%attribute(expression) The type of the specified attribute. The value of the specified attribute. The expression is treated as a string value and specifies the name of the attribute. If the specified attribute does not exist, a special undefined value is returned.
%create_time Date The create time of the object, which is a convenient equivalent to %attribute('create_time').
%date(expression) Date The date value converted from an ISO8601 formatted date string. The expression must be a string value in a valid ISO8601 format.
%encoding String The CharSet name of the best estimate of Groovy of the file encoding for the specific file.
%is_dir Boolean TRUE if the object is a directory, otherwise FALSE.
%is_executable Boolean TRUE if the object has executable permission, otherwise FALSE.
%is_link Boolean TRUE if the object is a symbolic link (on UNIX), otherwise FALSE.
%is_modifiable Boolean TRUE if the object has modifiable permission that allows the owner to modify it, otherwise FALSE.
%is_text Boolean TRUE if Rational Synergy determines the file has ascii contents, or FALSE if it has binary contents.
%locale String A string containing the locale value of the client system. This is the value returned using Locale.getDefault() in Java™. For example, it might return the string "en_US". For more information, see http://download.oracle.com/javase/6/docs/api/java/util/Locale.html#getDefault()
%mode Integer An integer containing the UNIX permissions mode for the source object, or the nearest equivalent value.
%modify_time Date The modify_time of the source object.
%name String The simple name of the source object. For a file or directory in the file system, this is the name of the file or directory without any path information.
%owner String The owner of the source object, which is a convenient equivalent to %attribute('owner').
%path String

A string containing the complete path of the source object.

For files being migrated, the exact meaning of this depends on the type of migrate plug-in used. If migrating from plain source, it is the full relative path from the top level migrate source directory, including the name of that directory (so no object has an empty path name).

For a Rational Synergy object, it is the name of a top-level object plus the relative path from that top-level object. For a file in a maintained work area, it includes the path of the file in that work area.

%release String The release of the source object, which is a convenient equivalent to %attribute('release').
%size Long The size of the object in bytes.
%status String The status of the source object, which is a convenient equivalent to %attribute('status').
%system_property(expression) String

Returns a string which is equivalent to calling System.getProperty(propertyName) in Java. The argument is a string value that must be a valid name of a Java system property.

For example, %system_property( 'user.language') might return the string "en_US".

For more information about the Java system properties, see http://download.oracle.com/javase/6/docs/api/java/lang/System.html#getProperties()

%tr(expression1, expression2, expression3[, expression4]) String

Returns a string which is the equivalent of piping the value of expression1 through the POSIX tr command using expression2 and expression3. See http://en.wikipedia.org/wiki/Tr_%28Unix%29 for details about the tr command.

The optional expression4 argument can have the value "c", "d", or "s". These correspond to the options -c (meaning complement), -d (meaning delete) and -s (meaning compress adjacent identical characters) respectively.

Example: %tr(%name, ’ab’, ’jk’)

The %tr in the example returns the name where each letter ’a’ and ’b’ are converted to letters ’j’ and ’k’ respectively.

This function can be used to map illegal or unwanted characters in a file name. A global mapping can be created using a rule of the form:

WHEN TRUE SET name to %tr(%name,"…","…")

%type String The Rational Synergy type of the source object, which is a convenient equivalent to %attribute('type').
%undefined Boolean TRUE if the expression is undefined, or FALSE if the expression is defined.
%version String The Rational Synergy version of the source object, which is a convenient equivalent to %attribute('version').

Feedback