Search in sources :

Example 6 with FormService

use of org.camunda.bpm.engine.FormService in project camunda-bpm-platform by camunda.

the class MockedProcessEngineProvider method mockServices.

private void mockServices(ProcessEngine engine) {
    RepositoryService repoService = mock(RepositoryService.class);
    IdentityService identityService = mock(IdentityService.class);
    TaskService taskService = mock(TaskService.class);
    RuntimeService runtimeService = mock(RuntimeService.class);
    FormService formService = mock(FormService.class);
    HistoryService historyService = mock(HistoryService.class);
    ManagementService managementService = mock(ManagementService.class);
    CaseService caseService = mock(CaseService.class);
    FilterService filterService = mock(FilterService.class);
    ExternalTaskService externalTaskService = mock(ExternalTaskService.class);
    when(engine.getRepositoryService()).thenReturn(repoService);
    when(engine.getIdentityService()).thenReturn(identityService);
    when(engine.getTaskService()).thenReturn(taskService);
    when(engine.getRuntimeService()).thenReturn(runtimeService);
    when(engine.getFormService()).thenReturn(formService);
    when(engine.getHistoryService()).thenReturn(historyService);
    when(engine.getManagementService()).thenReturn(managementService);
    when(engine.getCaseService()).thenReturn(caseService);
    when(engine.getFilterService()).thenReturn(filterService);
    when(engine.getExternalTaskService()).thenReturn(externalTaskService);
}
Also used : IdentityService(org.camunda.bpm.engine.IdentityService) ManagementService(org.camunda.bpm.engine.ManagementService) RuntimeService(org.camunda.bpm.engine.RuntimeService) TaskService(org.camunda.bpm.engine.TaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) ExternalTaskService(org.camunda.bpm.engine.ExternalTaskService) FormService(org.camunda.bpm.engine.FormService) FilterService(org.camunda.bpm.engine.FilterService) HistoryService(org.camunda.bpm.engine.HistoryService) CaseService(org.camunda.bpm.engine.CaseService) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 7 with FormService

use of org.camunda.bpm.engine.FormService in project camunda-bpm-platform by camunda.

the class ProcessDefinitionResourceImpl method getRenderedForm.

public Response getRenderedForm() {
    FormService formService = engine.getFormService();
    Object startForm = formService.getRenderedStartForm(processDefinitionId);
    if (startForm != null) {
        String content = startForm.toString();
        InputStream stream = new ByteArrayInputStream(content.getBytes(EncodingUtil.DEFAULT_ENCODING));
        return Response.ok(stream).type(MediaType.APPLICATION_XHTML_XML).build();
    }
    throw new InvalidRequestException(Status.NOT_FOUND, "No matching rendered start form for process definition with the id " + processDefinitionId + " found.");
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FormService(org.camunda.bpm.engine.FormService) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 8 with FormService

use of org.camunda.bpm.engine.FormService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method getFormVariables.

public Map<String, VariableValueDto> getFormVariables(String variableNames, boolean deserializeValues) {
    final FormService formService = engine.getFormService();
    List<String> formVariables = null;
    if (variableNames != null) {
        StringListConverter stringListConverter = new StringListConverter();
        formVariables = stringListConverter.convertQueryParameterToType(variableNames);
    }
    VariableMap startFormVariables = formService.getTaskFormVariables(taskId, formVariables, deserializeValues);
    return VariableValueDto.fromVariableMap(startFormVariables);
}
Also used : StringListConverter(org.camunda.bpm.engine.rest.dto.converter.StringListConverter) VariableMap(org.camunda.bpm.engine.variable.VariableMap) FormService(org.camunda.bpm.engine.FormService)

Example 9 with FormService

use of org.camunda.bpm.engine.FormService in project camunda-bpm-platform by camunda.

the class TaskResourceImpl method submit.

public void submit(CompleteTaskDto dto) {
    FormService formService = engine.getFormService();
    try {
        VariableMap variables = VariableValueDto.toMap(dto.getVariables(), engine, objectMapper);
        formService.submitTaskForm(taskId, variables);
    } catch (RestException e) {
        String errorMessage = String.format("Cannot submit task form %s: %s", taskId, e.getMessage());
        throw new InvalidRequestException(e.getStatus(), e, errorMessage);
    } catch (AuthorizationException e) {
        throw e;
    } catch (ProcessEngineException e) {
        String errorMessage = String.format("Cannot submit task form %s: %s", taskId, e.getMessage());
        throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    }
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) AuthorizationException(org.camunda.bpm.engine.AuthorizationException) FormService(org.camunda.bpm.engine.FormService) RestException(org.camunda.bpm.engine.rest.exception.RestException) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Aggregations

FormService (org.camunda.bpm.engine.FormService)9 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)5 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RestException (org.camunda.bpm.engine.rest.exception.RestException)3 VariableMap (org.camunda.bpm.engine.variable.VariableMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 IdentityService (org.camunda.bpm.engine.IdentityService)2 StringListConverter (org.camunda.bpm.engine.rest.dto.converter.StringListConverter)2 FormDto (org.camunda.bpm.engine.rest.dto.task.FormDto)2 URI (java.net.URI)1 CaseService (org.camunda.bpm.engine.CaseService)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 FilterService (org.camunda.bpm.engine.FilterService)1 HistoryService (org.camunda.bpm.engine.HistoryService)1 ManagementService (org.camunda.bpm.engine.ManagementService)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 RuntimeService (org.camunda.bpm.engine.RuntimeService)1 TaskService (org.camunda.bpm.engine.TaskService)1