I found the answer. A note at the top of the page for PromptSetDefinition
states:
This class is created using the request com.uc4.communication.AddPromptSet An instance of this class can be added to executable Objects (for example Jobs) and default values for PromptElements can be set.
The page for AddPromtSet
does not clearly describe how to do this, but I figured it out eventually. It’s a multi-step process that involves instantiating one UC4ObjectName object (for the prompt set name) and two UC4Object ones (one for the prompt set, and another for the executable object to which you wish to attach it).
private static void attachPromptSet(Connection myConnection, String execObjName, String promptSetName) throws IOException {
UC4ObjectName promptSetUc4Name = new UC4ObjectName(promptSetName);
UC4Object promptSetObject = openObject(myConnection,oIpromptSetName,true);
AddPromptSet addPromptSet = new AddPromptSet(promptSetUc4Name , promptSetObject);
myConnection.sendRequestAndWait(addPromptSet);
closeObject(myConnection,promptSetObject);
PromptSetDefinition promptSetDefinition = addPromptSet.getPromptSet();
UC4Object executableUc4Object = openObject(myConnection, execObjName, false);
ObjectValues objectValues = getObjectValues(executableUc4Object);
objectValues.addPromptSet(new PromptSetDefinition(promptSetDefinition));
saveObject(myConnection, executableUc4Object);
closeObject(myConnection,executableUc4Object);
}
In the above example, openObject
, saveObject
, and closeObject
are simply wrapper methods I created to use the OpenObject
, SaveObject
, and CloseObject
classes & then run Connection.sendRequestAndWait()
.
The getObjectValues
method might be interesting, so I’ll include it here. It is provides a way to get the ObjectValues
of an executable object regardless of its type.
public static ObjectValues getObjectValues(UC4Object uc4Object) {
ObjectValues objectValues = null;
String objectName = uc4Object.getName();
String uc4ObjectClassName = uc4Object.getClass().getSimpleName();
System.out.println(String.format("Object is an instance of class %s.", uc4ObjectClassName));
switch (uc4ObjectClassName) {
case "JobPlan":
System.out.println(String.format("Object %s is a standard workflow.", objectName));
objectValues = ((JobPlan) uc4Object).values();
break;
case "WorkflowIF":
System.out.println(String.format("Object %s is an IF workflow.", objectName));
objectValues = ((WorkflowIF) uc4Object).values();
break;
case "WorkflowLoop":
System.out.println(String.format("Object %s is a FOREACH workflow.", objectName));
objectValues = ((WorkflowLoop) uc4Object).values();
break;
case "Schedule":
System.out.println(String.format("Object %s is a Schedule.", objectName));
objectValues = ((Schedule) uc4Object).values();
break;
case "Script":
System.out.println(String.format("Object %s is a Script.", objectName));
objectValues = ((Script) uc4Object).values();
break;
case "TimeEvent":
System.out.println(String.format("Object %s is a Time Event.", objectName));
objectValues = ((TimeEvent) uc4Object).values();
break;
case "FileEvent":
System.out.println(String.format("Object %s is a File Event.", objectName));
objectValues = ((FileEvent) uc4Object).values();
break;
case "DatabaseEvent":
System.out.println(String.format("Object %s is a DB Event.", objectName));
objectValues = ((DatabaseEvent) uc4Object).values();
break;
case "ConsoleEvent":
System.out.println(String.format("Object %s is a Console Event.", objectName));
objectValues = ((ConsoleEvent) uc4Object).values();
break;
case "Job":
System.out.println(String.format("Object %s is an OS Job.", objectName));
objectValues = ((Job) uc4Object).values();
break;
case "FileTransfer":
System.out.println(String.format("Object %s is a File Transfer.", objectName));
objectValues = ((FileTransfer) uc4Object).values();
break;
default:
System.out.println(String.format("Unknown object type."));
objectValues = null;
}
return objectValues;
}
There’s surely a more concise & elegant way to do this, but it works.