Search in sources :

Example 11 with StartFormData

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

the class MockProvider method createMockStartFormDataUsingFormFieldsWithoutFormKey.

public static StartFormData createMockStartFormDataUsingFormFieldsWithoutFormKey(ProcessDefinition definition) {
    FormField mockFormField = mock(FormField.class);
    when(mockFormField.getId()).thenReturn(EXAMPLE_FORM_PROPERTY_ID);
    when(mockFormField.getLabel()).thenReturn(EXAMPLE_FORM_PROPERTY_NAME);
    when(mockFormField.getDefaultValue()).thenReturn(EXAMPLE_FORM_PROPERTY_VALUE);
    FormType mockFormType = mock(FormType.class);
    when(mockFormType.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_TYPE_NAME);
    when(mockFormField.getType()).thenReturn(mockFormType);
    StartFormData mockFormData = mock(StartFormData.class);
    when(mockFormData.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
    when(mockFormData.getProcessDefinition()).thenReturn(definition);
    List<FormField> mockFormFields = new ArrayList<FormField>();
    mockFormFields.add(mockFormField);
    when(mockFormData.getFormFields()).thenReturn(mockFormFields);
    return mockFormData;
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) FormType(org.camunda.bpm.engine.form.FormType) ArrayList(java.util.ArrayList) HistoricFormField(org.camunda.bpm.engine.history.HistoricFormField) FormField(org.camunda.bpm.engine.form.FormField)

Example 12 with StartFormData

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

the class MockProvider method createMockStartFormData.

// form data
public static StartFormData createMockStartFormData(ProcessDefinition definition) {
    FormProperty mockFormProperty = mock(FormProperty.class);
    when(mockFormProperty.getId()).thenReturn(EXAMPLE_FORM_PROPERTY_ID);
    when(mockFormProperty.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_NAME);
    when(mockFormProperty.getValue()).thenReturn(EXAMPLE_FORM_PROPERTY_VALUE);
    when(mockFormProperty.isReadable()).thenReturn(EXAMPLE_FORM_PROPERTY_READABLE);
    when(mockFormProperty.isWritable()).thenReturn(EXAMPLE_FORM_PROPERTY_WRITABLE);
    when(mockFormProperty.isRequired()).thenReturn(EXAMPLE_FORM_PROPERTY_REQUIRED);
    FormType mockFormType = mock(FormType.class);
    when(mockFormType.getName()).thenReturn(EXAMPLE_FORM_PROPERTY_TYPE_NAME);
    when(mockFormProperty.getType()).thenReturn(mockFormType);
    StartFormData mockFormData = mock(StartFormData.class);
    when(mockFormData.getFormKey()).thenReturn(EXAMPLE_FORM_KEY);
    when(mockFormData.getDeploymentId()).thenReturn(EXAMPLE_DEPLOYMENT_ID);
    when(mockFormData.getProcessDefinition()).thenReturn(definition);
    List<FormProperty> mockFormProperties = new ArrayList<FormProperty>();
    mockFormProperties.add(mockFormProperty);
    when(mockFormData.getFormProperties()).thenReturn(mockFormProperties);
    return mockFormData;
}
Also used : FormProperty(org.camunda.bpm.engine.form.FormProperty) StartFormData(org.camunda.bpm.engine.form.StartFormData) FormType(org.camunda.bpm.engine.form.FormType) ArrayList(java.util.ArrayList)

Example 13 with StartFormData

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

the class GetRenderedStartFormCmd method execute.

public Object execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    ensureNotNull("Process Definition '" + processDefinitionId + "' not found", "processDefinition", processDefinition);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessDefinition(processDefinition);
    }
    StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
    if (startFormHandler == null) {
        return null;
    }
    FormEngine formEngine = Context.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);
    StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
    Object renderedStartForm = null;
    try {
        renderedStartForm = formEngine.renderStartForm(startForm);
    } catch (ScriptEvaluationException e) {
        LOG.exceptionWhenStartFormScriptEvaluation(processDefinitionId, e);
    }
    return renderedStartForm;
}
Also used : StartFormHandler(org.camunda.bpm.engine.impl.form.handler.StartFormHandler) ScriptEvaluationException(org.camunda.bpm.engine.ScriptEvaluationException) StartFormData(org.camunda.bpm.engine.form.StartFormData) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) FormEngine(org.camunda.bpm.engine.impl.form.engine.FormEngine)

Example 14 with StartFormData

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

the class ElResolveStartFormDataTest method testStartFormDataWithDefaultValueExpression.

@Test
public void testStartFormDataWithDefaultValueExpression() {
    String processDefinitionId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    StartFormData formData = formService.getStartFormData(processDefinitionId);
    Object defaultValue = formData.getFormFields().get(0).getValue().getValue();
    Assert.assertNotNull(defaultValue);
    Assert.assertEquals("testString123", defaultValue);
}
Also used : StartFormData(org.camunda.bpm.engine.form.StartFormData) AbstractFoxPlatformIntegrationTest(org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest) Test(org.junit.Test)

Example 15 with StartFormData

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

the class GetStartFormVariablesCmd method execute.

public VariableMap execute(final CommandContext commandContext) {
    StartFormData startFormData = commandContext.runWithoutAuthorization(new Callable<StartFormData>() {

        public StartFormData call() throws Exception {
            return new GetStartFormCmd(resourceId).execute(commandContext);
        }
    });
    ProcessDefinition definition = startFormData.getProcessDefinition();
    checkGetStartFormVariables((ProcessDefinitionEntity) definition, commandContext);
    VariableMap result = new VariableMapImpl();
    for (FormField formField : startFormData.getFormFields()) {
        if (formVariableNames == null || formVariableNames.contains(formField.getId())) {
            result.put(formField.getId(), createVariable(formField, null));
        }
    }
    return result;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) FormField(org.camunda.bpm.engine.form.FormField)

Aggregations

StartFormData (org.camunda.bpm.engine.form.StartFormData)19 Test (org.junit.Test)10 Deployment (org.camunda.bpm.engine.test.Deployment)5 FormField (org.camunda.bpm.engine.form.FormField)4 FormProperty (org.camunda.bpm.engine.form.FormProperty)4 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 VariableMap (org.camunda.bpm.engine.variable.VariableMap)3 LinkedHashMap (java.util.LinkedHashMap)2 FormType (org.camunda.bpm.engine.form.FormType)2 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)2 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)1 FormService (org.camunda.bpm.engine.FormService)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 ScriptEvaluationException (org.camunda.bpm.engine.ScriptEvaluationException)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1