Rational Developer for System z, Version 7.6

Dealing with custom parameters

RAM developers have the ability to either customize existing CARMA actions or to create entirely new actions. These actions may have custom parameters or return values as defined by the configuration of the CARMA host.

There are several helper classes available so that you can easily make use of these custom actions:

CustomActionParameterManager
Queries the default, stored, and link values (retrieved in the order specified in the CARMA preferences) against the metadata
CustomActionParameterDialog
A convenience dialog that simply asks users to enter values for custom parameters
CustomActionUtil
A helper class providing various convenience methods

Using the custom action helper classes

The simplest way to obtain values for a custom parameter is to use one of the methods in CustomActionUtil; for example, getCustomParameters:

CustomActionUtil.getCustomParameters(resource, "101");

This retrieves the custom parameters for the action with an action ID of 101 for the given resource. If you plan on using the same task repeatedly for different, but similar, resources, you can use getCustomParametersForTask like so:

CARMAContent[] resources = getResources();
CarmaTaskMemento taskMemento  = new CarmaTaskMemento();
for (int i = 0; i < resources.length; i++) {
        CustomActionUtil.getCustomParametersForTask(taskMemento, resources[i], "101");
}

In the above example, taskMemento is used to store information the user has entered for use between action invocations. If taskMemento were not to be used here, the user would be queried with the same prompts for every resource.

If you would rather use a different mechanism to fetch parameter values (such as a different user interface), you could interact directly with the CustomActionParameterManager class, as illustrated in the following example:

CustomActionParameterManager manager = CustomActionParameterManager.getManager();
Object[] paramsToPass = manager.getCustomParameters(resource, actionId); // parameters to pass to the command
//this method will tell us whether or not the manager has all the information it needs
if (manager.isPromptNeeded(resource, actionId)) {
        final Action action = resource.findActionFor(actionId);

        Iterator parameters = action.getParameters().iterator();

        //find the parameter you want to change this way, or look for it to be null in paramsToPass
        int index = 0;
        while (it.hasNext()) {
                Parameter param = (Parameter) it.next();
                if (param.getName().equals(targetName))
                        break;
                index++;
        }

        paramsToPass[index] = new Boolean(false);

        //optionally store the parameter for later
        Object[] paramsToStore = new Object[paramsToPass.length];
        for (int i = 0; i < paramsToStore.length; i++) {
                paramsToStore[i] = null;
                if (i == index)
                        paramsToStore[i] = new Boolean(false);
        }
        manager.setUserStoredParamValues(resource.getRepository(), paramsToStore);
}

In the example above, targetName is the name of the parameter as defined by the RAM developer.


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)