Class PromptQueryTestViewModel
java.lang.Object
de.xima.fc.prompt.mgmt.gui.model.PromptQueryTestViewModel
- All Implemented Interfaces:
Serializable
View model for testing a prompt query. Contains the information needed to render the test UI, such as the input
parameters and file controls. It also contains the result of the latest test execution, if any.
- Since:
- 8.5.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic PromptQueryTestViewModelforControls(ValueDescriptorFormModel jsonPropertiesForm, List<PromptTestFileInput> fileControls, IValueAccessor<Object> jsonParameters, Map<String, List<PromptTestFile>> uploadedFiles) Creates a new view model for the prompt query action configuration UI; when the configuration could be loaded successfully.static PromptQueryTestViewModelCreates a new view model for the prompt query action configuration UI; when an error occurred.getError()If this model represents anerror state, gets the error message.Gets the controls for editing the file inputs of the prompt query.Gets the JSON object with the configured input parameters, which needs to conform to theJSON input descriptorof the prompt query.Gets the properties form for editing theJSON object.Gets the result of the last prompt query test execution, if any.Gets the list with the uploaded files for the file inputs.booleanChecks whether this model represents an error state, i.e. when the test model could not be created properly, such as when the prompt service failed to return an input descriptor.voidupdateControls(ValueDescriptorFormModel jsonPropertiesForm, List<PromptTestFileInput> fileControls) Updates this test view model with the given controls, i.e. changes the controls to the given ones and clears any previous error.voidUpdates this test view model with the given execution result from the latest prompt query test execution.
-
Method Details
-
getError
If this model represents anerror state, gets the error message.- Returns:
- The error message, or null if there is no error.
-
getFileControls
Gets the controls for editing the file inputs of the prompt query. The structure of the controls is based on thefile input descriptorof the prompt query.- Returns:
- The controls for editing the file inputs.
-
getJsonParameters
Gets the JSON object with the configured input parameters, which needs to conform to theJSON input descriptorof the prompt query.- Returns:
- The JSON object with the configured input parameters.
-
getJsonPropertiesForm
Gets the properties form for editing theJSON object. The structure of the form is based on theJSON input descriptorof the prompt query.- Returns:
- The properties form for editing the JSON object.
-
getLastExecutionResult
Gets the result of the last prompt query test execution, if any.- Returns:
- The result of the last execution, or null if no execution has been performed yet.
-
getUploadedFiles
Gets the list with the uploaded files for the file inputs. The list contains one item for eachfile keyfrom the prompt queryfile input descriptor.- Returns:
- The map with the uploaded files.
-
isHasError
public boolean isHasError()Checks whether this model represents an error state, i.e. when the test model could not be created properly, such as when the prompt service failed to return an input descriptor. If so,getError()returns the error message; and other methods such asgetJsonPropertiesFormreturn empty or null values.- Returns:
- True if this model represents an error state; false otherwise.
-
updateControls
public void updateControls(ValueDescriptorFormModel jsonPropertiesForm, List<PromptTestFileInput> fileControls) Updates this test view model with the given controls, i.e. changes the controls to the given ones and clears any previous error.- Parameters:
jsonPropertiesForm- The dynamic form model for the JSON input parameters of the selected prompt query.fileControls- The controls for editing the file parameters.
-
updateLastExecutionResult
Updates this test view model with the given execution result from the latest prompt query test execution. Leaves all other properties unchanged.- Parameters:
result- The result of the latest prompt query test execution.
-
forControls
public static PromptQueryTestViewModel forControls(ValueDescriptorFormModel jsonPropertiesForm, List<PromptTestFileInput> fileControls, IValueAccessor<Object> jsonParameters, Map<String, List<PromptTestFile>> uploadedFiles) Creates a new view model for the prompt query action configuration UI; when the configuration could be loaded successfully.- Parameters:
jsonPropertiesForm- The dynamic form model for the JSON input parameters of the selected prompt query.fileControls- The controls for editing the file parameters.jsonParameters- The JSON object with the configured input parameters.uploadedFiles- The list with files that were uploaded for each file input.
-
forError
Creates a new view model for the prompt query action configuration UI; when an error occurred.- Parameters:
error- The error message.
-