INSERT {
IMPORT com.telelogic.cm.migrate.MigrateObject;
IMPORT static java.util.Calendar.*;
}
WHEN { migrateObject.type() == 'executable' &&
Calendar.getInstance().get(DAY_OF_WEEK) != FRIDAY } IGNORE
This sample rule sets the 'day' attribute on all files named '*.day' to the name of the week day. While this rule might not be useful, it illustrates how to write an action in Groovy while leaving the condition in written using built-in condition.
IMPORT com.telelogic.cm.migrate.MigrateObject;
IMPORT org.joda.time.*;
WHEN %name ~ '*.day' { migrateObject.setAttribute('day', getWeekDay()) }
INSERT
{
String getWeekDay()
{
return new DateTime().dayOfWeek().getAsText();
}
}