FilterFindParameterQuery { public List<TaskParameterView> filter( List<TaskParameterView> params, TaskParameterFilter filter, Task optionalTask, WorkflowDefinition wd) { Map<String, Map<String, ParamEntry>> join = new LinkedHashMap<String, Map<String, ParamEntry>>(); if (params.isEmpty() && optionalTask != null) { TaskParameterView param = new TaskParameterView(); param.setJobId(optionalTask.getJobId()); param.setTaskId(optionalTask.getId()); param.setTaskProfileName(optionalTask.getTypeRef()); selectProfileTaskParams(join, param, wd); } for (TaskParameterView param : params) { Map<String, ParamEntry> taskParamCache = selectProfileTaskParams(join, param, wd); outerJoinDbParamsWithProfileParams(taskParamCache, param, filter); } return outerJoinProfileParamsWithDbParams(join, filter); } FilterFindParameterQuery(WorkflowProfiles wp); List<TaskParameterView> filter(
            List<TaskParameterView> params,
            TaskParameterFilter filter,
            Task optionalTask,
            WorkflowDefinition wd);  }
@Test public void testFilterNoDbParam() { List<TaskParameterView> params = Collections.emptyList(); TaskParameterFilter filter = new TaskParameterFilter(); filter.setTaskId(BigDecimal.TEN); filter.setLocale(Locale.ENGLISH); Task task = new Task(); task.setTypeRef("task.id1"); task.setId(filter.getTaskId()); List<TaskParameterView> result = new FilterFindParameterQuery(wp).filter(params, filter, task, wp.getProfiles()); assertEquals(2, result.size()); assertEquals("param.id1", result.get(0).getParamRef()); assertEquals(DisplayType.TEXT, result.get(0).getDisplayType()); assertEquals(task.getTypeRef(), result.get(0).getTaskProfileName()); assertEquals(filter.getTaskId(), result.get(0).getTaskId()); }
@Test public void testFilter() { String taskProfileName = "task.id1"; TaskParameterView dbParam2 = new TaskParameterView(); dbParam2.setJobId(BigDecimal.ZERO); dbParam2.setParamRef("param.id2"); dbParam2.setTaskId(BigDecimal.TEN); dbParam2.setTaskProfileName(taskProfileName); dbParam2.addValueString("testVal"); List<TaskParameterView> params = Arrays.asList(dbParam2); TaskParameterFilter filter = new TaskParameterFilter(); filter.setTaskId(BigDecimal.TEN); filter.setLocale(Locale.ENGLISH); List<TaskParameterView> result = new FilterFindParameterQuery(wp) .filter(params, filter, null, wp.getProfiles()); assertEquals(2, result.size()); assertEquals("param.id1", result.get(0).getParamRef()); assertEquals(DisplayType.TEXT, result.get(0).getDisplayType()); assertEquals(taskProfileName, result.get(0).getTaskProfileName()); assertEquals(filter.getTaskId(), result.get(0).getTaskId()); assertEquals("param.id2", result.get(1).getParamRef()); assertEquals("testVal", result.get(1).getValue()); assertEquals(DisplayType.TEXT, result.get(1).getDisplayType()); assertEquals(taskProfileName, result.get(1).getTaskProfileName()); assertEquals(filter.getTaskId(), result.get(1).getTaskId()); }