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;
}
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;
}
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;
}
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);
}
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;
}
Aggregations