Search in sources :

Example 1 with FormData

use of org.activiti.engine.form.FormData in project Activiti by Activiti.

the class FormDataResource method getFormData.

@RequestMapping(value = "/form/form-data", method = RequestMethod.GET, produces = "application/json")
public FormDataResponse getFormData(@RequestParam(value = "taskId", required = false) String taskId, @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId, HttpServletRequest request) {
    if (taskId == null && processDefinitionId == null) {
        throw new ActivitiIllegalArgumentException("The taskId or processDefinitionId parameter has to be provided");
    }
    if (taskId != null && processDefinitionId != null) {
        throw new ActivitiIllegalArgumentException("Not both a taskId and a processDefinitionId parameter can be provided");
    }
    FormData formData = null;
    String id = null;
    if (taskId != null) {
        formData = formService.getTaskFormData(taskId);
        id = taskId;
    } else {
        formData = formService.getStartFormData(processDefinitionId);
        id = processDefinitionId;
    }
    if (formData == null) {
        throw new ActivitiObjectNotFoundException("Could not find a form data with id '" + id + "'.", FormData.class);
    }
    return restResponseFactory.createFormDataResponse(formData);
}
Also used : FormData(org.activiti.engine.form.FormData) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 FormData (org.activiti.engine.form.FormData)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1