Source:
<code>public ModelAndView setupForm(@PathVariable Long poolId, ModelMap model) throws IOException { try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); Pool pool = null; if (poolId == AbstractPool.UNSAVED_ID) { pool = dataObjectFactory.getPool(user); model.put("title", "New Pool"); } else { pool = requestManager.getPoolById(poolId); model.put("title", "Pool " + poolId); } if (pool == null) { throw new SecurityException("No such Pool"); } if (!pool.userCanRead(user)) { throw new SecurityException("Permission denied."); } model.put("formObj", pool); model.put("pool", pool); model.put("availableDilutions", populateAvailableDilutions(pool)); model.put("accessibleExperiments", populateExperiments(null, pool)); model.put("owners", LimsSecurityUtils.getPotentialOwners(user, pool, securityManager.listAllUsers())); model.put("accessibleUsers", LimsSecurityUtils.getAccessibleUsers(user, pool, securityManager.listAllUsers())); model.put("accessibleGroups", LimsSecurityUtils.getAccessibleGroups(user, pool, securityManager.listAllGroups())); Collection<SequencingParametersDto> sequencingParameters = Dtos.asSequencingParametersDtos(sequencingParametersService.getAll()); model.put("sequencingParameters", sequencingParameters); JSONArray array = new JSONArray(); array.addAll(sequencingParameters); model.put("sequencingParametersJson", array.toString()); <START> model.put("platforms", getFilteredPlatforms(pool.getPlatformType())); <END> return new ModelAndView("/pages/editPool.jsp", model); } catch (IOException ex) { if (log.isDebugEnabled()) { log.debug("Failed to show pool", ex); } throw ex; } }</code><technical_language>a @ModelAttribute method include in models avoid duplication</technical_language>

Target:
public ModelAndView setupForm(@PathVariable Long poolId, ModelMap model) throws IOException { try { User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName()); Pool pool = null; if (poolId == AbstractPool.UNSAVED_ID) { pool = dataObjectFactory.getPool(user); model.put("title", "New Pool"); } else { pool = requestManager.getPoolById(poolId); model.put("title", "Pool " + poolId); } if (pool == null) { throw new SecurityException("No such Pool"); } if (!pool.userCanRead(user)) { throw new SecurityException("Permission denied."); } model.put("formObj", pool); model.put("pool", pool); model.put("availableDilutions", populateAvailableDilutions(pool)); model.put("accessibleExperiments", populateExperiments(null, pool)); model.put("owners", LimsSecurityUtils.getPotentialOwners(user, pool, securityManager.listAllUsers())); model.put("accessibleUsers", LimsSecurityUtils.getAccessibleUsers(user, pool, securityManager.listAllUsers())); model.put("accessibleGroups", LimsSecurityUtils.getAccessibleGroups(user, pool, securityManager.listAllGroups())); model.put("platforms", getFilteredPlatforms(pool.getPlatformType())); model.put("ordercompletions", poolOrderCompletionService.getOrderCompletionForPool(poolId)); return new ModelAndView("/pages/editPool.jsp", model); } catch (IOException ex) { if (log.isDebugEnabled()) { log.debug("Failed to show pool", ex); } throw ex; } }