Package de.xima.fc.prompt.mgmt.gui.model
Class PromptQueryTestViewModel
- java.lang.Object
-
- de.xima.fc.prompt.mgmt.gui.model.PromptQueryTestViewModel
-
- All Implemented Interfaces:
Serializable
public class PromptQueryTestViewModel extends Object implements 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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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 PromptQueryTestViewModelforError(String error)Creates a new view model for the prompt query action configuration UI; when an error occurred.StringgetError()If this model represents anerror state, gets the error message.List<PromptTestFileInput>getFileControls()Gets the controls for editing the file inputs of the prompt query.IValueAccessor<Object>getJsonParameters()Gets the JSON object with the configured input parameters, which needs to conform to theJSON input descriptorof the prompt query.ValueDescriptorFormModelgetJsonPropertiesForm()Gets the properties form for editing theJSON object.PromptQueryTestExecutionResultgetLastExecutionResult()Gets the result of the last prompt query test execution, if any.Map<String,List<PromptTestFile>>getUploadedFiles()Gets the list with the uploaded files for the file inputs.booleanisHasError()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.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.voidupdateLastExecutionResult(PromptQueryTestExecutionResult result)Updates this test view model with the given execution result from the latest prompt query test execution.
-
-
-
Method Detail
-
getError
public String getError()
If this model represents anerror state, gets the error message.- Returns:
- The error message, or null if there is no error.
-
getFileControls
public List<PromptTestFileInput> 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
public IValueAccessor<Object> 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
public ValueDescriptorFormModel 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
public PromptQueryTestExecutionResult 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
public Map<String,List<PromptTestFile>> 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
public void updateLastExecutionResult(PromptQueryTestExecutionResult result)
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
public static PromptQueryTestViewModel forError(String error)
Creates a new view model for the prompt query action configuration UI; when an error occurred.- Parameters:
error- The error message.
-
-