org.activiti.engine.form.FormProperty Java Examples
The following examples show how to use
org.activiti.engine.form.FormProperty.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitiResourceMapperTest.java From crnk-framework with Apache License 2.0 | 6 votes |
@Test public void checkForm() { Map<String, Object> variables = mapper.mapToVariables(formResource); Assert.assertEquals(1, variables.size()); Assert.assertEquals(Boolean.TRUE, variables.get("approved")); TestForm resourceCopy = new TestForm(); mapper.mapFromVariables(resourceCopy, variables); checkFormResource(resourceCopy); List<FormProperty> formProperties = new ArrayList<>(); FormProperty formProperty = Mockito.mock(FormProperty.class); Mockito.when(formProperty.getId()).thenReturn("approved"); Mockito.when(formProperty.getValue()).thenReturn("true"); formProperties.add(formProperty); TaskFormData formData = Mockito.mock(TaskFormData.class); Mockito.when(formData.getFormProperties()).thenReturn(formProperties); Task task = Mockito.mock(Task.class); Mockito.when(task.getId()).thenReturn("someTask"); Mockito.when(formData.getTask()).thenReturn(task); TestForm formCopy = mapper.mapToResource(TestForm.class, formData); checkFormResource(formCopy); Assert.assertEquals("someTask", formCopy.getId()); }
Example #2
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #3
Source File: FormServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testFormPropertyExpression() { Map<String, Object> varMap = new HashMap<String, Object>(); varMap.put("speaker", "Mike"); // variable name mapping Address address = new Address(); varMap.put("address", address); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, varMap); String taskId = taskService.createTaskQuery().singleResult().getId(); TaskFormData taskFormData = formService.getTaskFormData(taskId); List<FormProperty> formProperties = taskFormData.getFormProperties(); FormProperty propertySpeaker = formProperties.get(0); assertEquals("speaker", propertySpeaker.getId()); assertEquals("Mike", propertySpeaker.getValue()); assertEquals(2, formProperties.size()); Map<String, String> properties = new HashMap<String, String>(); properties.put("street", "Broadway"); formService.submitTaskFormData(taskId, properties); address = (Address) runtimeService.getVariable(processInstance.getId(), "address"); assertEquals("Broadway", address.getStreet()); }
Example #4
Source File: FormPropertyDefaultValueTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testDefaultValue() throws Exception { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("FormPropertyDefaultValueTest.testDefaultValue"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); TaskFormData formData = formService.getTaskFormData(task.getId()); List<FormProperty> formProperties = formData.getFormProperties(); assertEquals(4, formProperties.size()); for (FormProperty prop : formProperties) { if ("booleanProperty".equals(prop.getId())) { assertEquals("true", prop.getValue()); } else if ("stringProperty".equals(prop.getId())) { assertEquals("someString", prop.getValue()); } else if ("longProperty".equals(prop.getId())) { assertEquals("42", prop.getValue()); } else if ("longExpressionProperty".equals(prop.getId())) { assertEquals("23", prop.getValue()); } else { assertTrue("Invalid form property: " + prop.getId(), false); } } Map<String, String> formDataUpdate = new HashMap<String, String>(); formDataUpdate.put("longExpressionProperty", "1"); formDataUpdate.put("booleanProperty", "false"); formService.submitTaskFormData(task.getId(), formDataUpdate); assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty")); assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty")); assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty")); assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty")); }
Example #5
Source File: FormPropertyDefaultValueTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testStartFormDefaultValue() throws Exception { String processDefinitionId = repositoryService.createProcessDefinitionQuery() .processDefinitionKey("FormPropertyDefaultValueTest.testDefaultValue") .latestVersion() .singleResult() .getId(); StartFormData startForm = formService.getStartFormData(processDefinitionId); List<FormProperty> formProperties = startForm.getFormProperties(); assertEquals(4, formProperties.size()); for (FormProperty prop : formProperties) { if ("booleanProperty".equals(prop.getId())) { assertEquals("true", prop.getValue()); } else if ("stringProperty".equals(prop.getId())) { assertEquals("someString", prop.getValue()); } else if ("longProperty".equals(prop.getId())) { assertEquals("42", prop.getValue()); } else if ("longExpressionProperty".equals(prop.getId())) { assertEquals("23", prop.getValue()); } else { assertTrue("Invalid form property: " + prop.getId(), false); } } // Override 2 properties. The others should pe posted as the default-value Map<String, String> formDataUpdate = new HashMap<String, String>(); formDataUpdate.put("longExpressionProperty", "1"); formDataUpdate.put("booleanProperty", "false"); ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataUpdate); assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty")); assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty")); assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty")); assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty")); }
Example #6
Source File: ActivitiResourceMapper.java From crnk-framework with Apache License 2.0 | 5 votes |
public <T extends FormResource> T mapToResource(Class<T> resourceClass, TaskFormData formData) { T resource = io.crnk.core.engine.internal.utils.ClassUtils.newInstance(resourceClass); Map<String, Object> formPropertyMap = new HashMap<>(); List<FormProperty> formProperties = formData.getFormProperties(); for (FormProperty formProperty : formProperties) { formPropertyMap.put(formProperty.getId(), formProperty.getValue()); } copyInternal(resource, null, formPropertyMap, true, Optional.empty()); resource.setId(formData.getTask().getId()); return resource; }
Example #7
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #8
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #9
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #10
Source File: DefaultFormHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinition processDefinition) { this.deploymentId = deployment.getId(); ExpressionManager expressionManager = Context .getProcessEngineConfiguration() .getExpressionManager(); if (StringUtils.isNotEmpty(formKey)) { this.formKey = expressionManager.createExpression(formKey); } FormTypes formTypes = Context .getProcessEngineConfiguration() .getFormTypes(); for (org.activiti.bpmn.model.FormProperty formProperty : formProperties) { FormPropertyHandler formPropertyHandler = new FormPropertyHandler(); formPropertyHandler.setId(formProperty.getId()); formPropertyHandler.setName(formProperty.getName()); AbstractFormType type = formTypes.parseFormPropertyType(formProperty); formPropertyHandler.setType(type); formPropertyHandler.setRequired(formProperty.isRequired()); formPropertyHandler.setReadable(formProperty.isReadable()); formPropertyHandler.setWritable(formProperty.isWriteable()); formPropertyHandler.setVariableName(formProperty.getVariable()); if (StringUtils.isNotEmpty(formProperty.getExpression())) { Expression expression = expressionManager.createExpression(formProperty.getExpression()); formPropertyHandler.setVariableExpression(expression); } if (StringUtils.isNotEmpty(formProperty.getDefaultExpression())) { Expression defaultExpression = expressionManager.createExpression(formProperty.getDefaultExpression()); formPropertyHandler.setDefaultExpression(defaultExpression); } formPropertyHandlers.add(formPropertyHandler); } }
Example #11
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #12
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #13
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #14
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #15
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #16
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #17
Source File: LeaveDynamicFormTest.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "chapter6/dynamic-form/leave.bpmn") public void testJavascriptFormType() throws Exception { // 验证是否部署成功 long count = repositoryService.createProcessDefinitionQuery().count(); assertEquals(1, count); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult(); StartFormData startFormData = formService.getStartFormData(processDefinition.getId()); List<FormProperty> formProperties = startFormData.getFormProperties(); for (FormProperty formProperty : formProperties) { System.out.println(formProperty.getId() + ",value=" + formProperty.getValue()); } }
Example #18
Source File: SimpleFlowWorkController.java From activiti-demo with Apache License 2.0 | 5 votes |
/** * 跳转到任务执行页面 * @param request * @return */ @RequestMapping(value = "/form.do") public String from(HttpServletRequest request, @RequestParam("taskId")String taskId, Model model){ List<Task> taskList = taskService.createTaskQuery().taskId(taskId).list(); Task task = taskList.get(0); //获取表单数据 TaskFormData tfd = formService.getTaskFormData(taskId); List<FormProperty> fpList = tfd.getFormProperties(); Map map = runtimeService.getVariables(task.getExecutionId()); List<ActivityImpl> activityList = new ArrayList<ActivityImpl>(); try { //查找所有可驳回的节点 activityList = processExtensionService.findBackActivity(taskId); //model.addAttribute("activityList",activityList); }catch (Exception e){ e.printStackTrace(); } // model.addAttribute("task",task); // model.addAttribute("fpList",fpList); // model.addAttribute("map",map); // model.addAttribute("taskId",taskId); request.setAttribute("task", task); request.setAttribute("fpList", fpList); request.setAttribute("map", map); request.setAttribute("taskId", taskId); request.setAttribute("activityList", activityList); return "/simple/form"; }
Example #19
Source File: DefaultFormHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void initializeFormProperties(FormDataImpl formData, ExecutionEntity execution) { List<FormProperty> formProperties = new ArrayList<FormProperty>(); for (FormPropertyHandler formPropertyHandler: formPropertyHandlers) { if (formPropertyHandler.isReadable()) { FormProperty formProperty = formPropertyHandler.createFormProperty(execution); formProperties.add(formProperty); } } formData.setFormProperties(formProperties); }
Example #20
Source File: FormPropertyHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public FormProperty createFormProperty(ExecutionEntity execution) { FormPropertyImpl formProperty = new FormPropertyImpl(this); Object modelValue = null; if (execution!=null) { if (variableName != null || variableExpression == null) { final String varName = variableName != null ? variableName : id; if (execution.hasVariable(varName)) { modelValue = execution.getVariable(varName); } else if (defaultExpression != null) { modelValue = defaultExpression.getValue(execution); } } else { modelValue = variableExpression.getValue(execution); } } else { // Execution is null, the form-property is used in a start-form. Default value // should be available (ACT-1028) even though no execution is available. if (defaultExpression != null) { modelValue = defaultExpression.getValue(NoExecutionVariableScope.getSharedInstance()); } } if (modelValue instanceof String) { formProperty.setValue((String) modelValue); } else if (type != null) { String formValue = type.convertModelValueToFormValue(modelValue); formProperty.setValue(formValue); } else if (modelValue != null) { formProperty.setValue(modelValue.toString()); } return formProperty; }
Example #21
Source File: FormPropertyDefaultValueTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testStartFormDefaultValue() throws Exception { String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("FormPropertyDefaultValueTest.testDefaultValue").latestVersion().singleResult().getId(); StartFormData startForm = formService.getStartFormData(processDefinitionId); List<FormProperty> formProperties = startForm.getFormProperties(); assertEquals(4, formProperties.size()); for (FormProperty prop : formProperties) { if ("booleanProperty".equals(prop.getId())) { assertEquals("true", prop.getValue()); } else if ("stringProperty".equals(prop.getId())) { assertEquals("someString", prop.getValue()); } else if ("longProperty".equals(prop.getId())) { assertEquals("42", prop.getValue()); } else if ("longExpressionProperty".equals(prop.getId())) { assertEquals("23", prop.getValue()); } else { assertTrue("Invalid form property: " + prop.getId(), false); } } // Override 2 properties. The others should pe posted as the // default-value Map<String, String> formDataUpdate = new HashMap<String, String>(); formDataUpdate.put("longExpressionProperty", "1"); formDataUpdate.put("booleanProperty", "false"); ProcessInstance processInstance = formService.submitStartFormData(processDefinitionId, formDataUpdate); assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty")); assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty")); assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty")); assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty")); }
Example #22
Source File: FormPropertyDefaultValueTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testDefaultValue() throws Exception { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("FormPropertyDefaultValueTest.testDefaultValue"); Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); TaskFormData formData = formService.getTaskFormData(task.getId()); List<FormProperty> formProperties = formData.getFormProperties(); assertEquals(4, formProperties.size()); for (FormProperty prop : formProperties) { if ("booleanProperty".equals(prop.getId())) { assertEquals("true", prop.getValue()); } else if ("stringProperty".equals(prop.getId())) { assertEquals("someString", prop.getValue()); } else if ("longProperty".equals(prop.getId())) { assertEquals("42", prop.getValue()); } else if ("longExpressionProperty".equals(prop.getId())) { assertEquals("23", prop.getValue()); } else { assertTrue("Invalid form property: " + prop.getId(), false); } } Map<String, String> formDataUpdate = new HashMap<String, String>(); formDataUpdate.put("longExpressionProperty", "1"); formDataUpdate.put("booleanProperty", "false"); formService.submitTaskFormData(task.getId(), formDataUpdate); assertEquals(false, runtimeService.getVariable(processInstance.getId(), "booleanProperty")); assertEquals("someString", runtimeService.getVariable(processInstance.getId(), "stringProperty")); assertEquals(42L, runtimeService.getVariable(processInstance.getId(), "longProperty")); assertEquals(1L, runtimeService.getVariable(processInstance.getId(), "longExpressionProperty")); }
Example #23
Source File: FormServiceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testFormPropertyExpression() { Map<String, Object> varMap = new HashMap<String, Object>(); varMap.put("speaker", "Mike"); // variable name mapping Address address = new Address(); varMap.put("address", address); String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, varMap); String taskId = taskService.createTaskQuery().singleResult().getId(); TaskFormData taskFormData = formService.getTaskFormData(taskId); List<FormProperty> formProperties = taskFormData.getFormProperties(); FormProperty propertySpeaker = formProperties.get(0); assertEquals("speaker", propertySpeaker.getId()); assertEquals("Mike", propertySpeaker.getValue()); assertEquals(2, formProperties.size()); Map<String, String> properties = new HashMap<String, String>(); properties.put("street", "Broadway"); formService.submitTaskFormData(taskId, properties); address = (Address) runtimeService.getVariable(processInstance.getId(), "address"); assertEquals("Broadway", address.getStreet()); }
Example #24
Source File: DefaultFormHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void parseConfiguration(List<org.activiti.bpmn.model.FormProperty> formProperties, String formKey, DeploymentEntity deployment, ProcessDefinition processDefinition) { this.deploymentId = deployment.getId(); ExpressionManager expressionManager = Context.getProcessEngineConfiguration().getExpressionManager(); if (StringUtils.isNotEmpty(formKey)) { this.formKey = expressionManager.createExpression(formKey); } FormTypes formTypes = Context.getProcessEngineConfiguration().getFormTypes(); for (org.activiti.bpmn.model.FormProperty formProperty : formProperties) { FormPropertyHandler formPropertyHandler = new FormPropertyHandler(); formPropertyHandler.setId(formProperty.getId()); formPropertyHandler.setName(formProperty.getName()); AbstractFormType type = formTypes.parseFormPropertyType(formProperty); formPropertyHandler.setType(type); formPropertyHandler.setRequired(formProperty.isRequired()); formPropertyHandler.setReadable(formProperty.isReadable()); formPropertyHandler.setWritable(formProperty.isWriteable()); formPropertyHandler.setVariableName(formProperty.getVariable()); if (StringUtils.isNotEmpty(formProperty.getExpression())) { Expression expression = expressionManager.createExpression(formProperty.getExpression()); formPropertyHandler.setVariableExpression(expression); } if (StringUtils.isNotEmpty(formProperty.getDefaultExpression())) { Expression defaultExpression = expressionManager.createExpression(formProperty.getDefaultExpression()); formPropertyHandler.setDefaultExpression(defaultExpression); } formPropertyHandlers.add(formPropertyHandler); } }
Example #25
Source File: DefaultFormHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void initializeFormProperties(FormDataImpl formData, ExecutionEntity execution) { List<FormProperty> formProperties = new ArrayList<FormProperty>(); for (FormPropertyHandler formPropertyHandler : formPropertyHandlers) { if (formPropertyHandler.isReadable()) { FormProperty formProperty = formPropertyHandler.createFormProperty(execution); formProperties.add(formProperty); } } formData.setFormProperties(formProperties); }
Example #26
Source File: FormPropertyHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public FormProperty createFormProperty(ExecutionEntity execution) { FormPropertyImpl formProperty = new FormPropertyImpl(this); Object modelValue = null; if (execution != null) { if (variableName != null || variableExpression == null) { final String varName = variableName != null ? variableName : id; if (execution.hasVariable(varName)) { modelValue = execution.getVariable(varName); } else if (defaultExpression != null) { modelValue = defaultExpression.getValue(execution); } } else { modelValue = variableExpression.getValue(execution); } } else { // Execution is null, the form-property is used in a start-form. // Default value // should be available (ACT-1028) even though no execution is // available. if (defaultExpression != null) { modelValue = defaultExpression.getValue(NoExecutionVariableScope.getSharedInstance()); } } if (modelValue instanceof String) { formProperty.setValue((String) modelValue); } else if (type != null) { String formValue = type.convertModelValueToFormValue(modelValue); formProperty.setValue(formValue); } else if (modelValue != null) { formProperty.setValue(modelValue.toString()); } return formProperty; }
Example #27
Source File: FormDataImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void setFormProperties(List<FormProperty> formProperties) { this.formProperties = formProperties; }
Example #28
Source File: AppTest.java From tutorial with MIT License | 4 votes |
@Test public void listTasks() { // 1. 查寻/设置 用户和组 logger.trace("query and create managers group and user waytt if they are not exist."); String groupId = "hosts"; String userId = "dolores"; //查询有没有ID为 managers 的组 List<Group> hostGroups = identityService.createGroupQuery().groupId(groupId).list(); Group hostGroup; if(hostGroups == null || hostGroups.size() == 0) { // 没有,增加一个 hostGroup = identityService.newGroup(groupId); //参数是groupId hostGroup.setName("接待员"); hostGroup.setType("business-role"); identityService.saveGroup(hostGroup); }else{ hostGroup = hostGroups.get(0); } List<User> users = identityService.createUserQuery().userId(userId).list(); User userDolores; if(users == null || users.size() == 0) { userDolores = identityService.newUser(userId); userDolores.setFirstName("Dolores"); userDolores.setLastName("Abernathy"); userDolores.setPassword("none"); userDolores.setEmail("[email protected]"); identityService.saveUser(userDolores); identityService.createMembership(userDolores.getId(), hostGroup.getId()); }else{ userDolores = users.get(0); } logger.trace("listTasks"); List<Task> tasks = taskService.createTaskQuery().list(); if(tasks == null || tasks.size() == 0){ logger.trace("donot found any tasks; add one"); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("applicantName", "Bernard Lowe"); variables.put("email", "[email protected]"); variables.put("phoneNumber", "123456789"); runtimeService.startProcessInstanceByKey("hireProcess", variables); }else{ for(Task t : tasks){ logger.trace(" task {}, {}, {}, {}, {}", t.getCategory(), t.getClaimTime(), t.getName(), t.getId(), t.getFormKey()); TaskFormData taskFormData = formService.getTaskFormData(t.getId()); List<FormProperty> formProperties = taskFormData.getFormProperties(); for (FormProperty property : formProperties) { logger.trace(" FormData property id: {}, name: {}, type: {} value: {}", property.getId(), property.getName(), property.getType(), property.getValue()); } } } //query again tasks = taskService.createTaskQuery().list(); assertTrue(tasks.size() > 0); for(int i=0; i<tasks.size() && i < 3; i++) { //认领几个任务(最多3个) Task task = tasks.get(i); //认领此任务 taskService.claim(task.getId(), userDolores.getId()); } //查看dolores用户当前的任务列表 List<Task> tasksOfDolores = taskService.createTaskQuery().taskAssignee(userDolores.getId()).list(); for (Task dt : tasksOfDolores) { logger.trace("Dolores's task: {}, {}, {}", dt.getId(), dt.getCreateTime(), dt.getProcessVariables()); // 设置此任务为完成状态 Map<String, Object> vars = new HashMap<>(); vars.put("telephoneInterviewOutcome", true); vars.put("techOk", false); vars.put("financialOk", true); taskService.complete(dt.getId(), vars); // 查询这个任务对应的流程的最终状态 HistoricProcessInstance hpi = historyService.createHistoricProcessInstanceQuery().processInstanceId(dt.getProcessInstanceId()).singleResult(); logger.trace("HistoricProcessInstance {}, {}, {}, {}", hpi.getName(), hpi.getEndActivityId(), hpi.getStartTime(), hpi.getEndTime()); } }
Example #29
Source File: FormDataImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public List<FormProperty> getFormProperties() { return formProperties; }
Example #30
Source File: FormDataImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void setFormProperties(List<FormProperty> formProperties) { this.formProperties = formProperties; }