Java Code Examples for org.activiti.engine.form.TaskFormData#getFormProperties()
The following examples show how to use
org.activiti.engine.form.TaskFormData#getFormProperties() .
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: 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 2
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 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: 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 6
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 7
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()); } }