List of usage examples for org.apache.commons.collections CollectionUtils addAll
public static void addAll(Collection collection, Object[] elements)
From source file:edu.isi.misd.scanner.network.registry.web.controller.SitePolicyController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<SitePolicy> getSitePolicies(@RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME, REQUEST_PARAM_SITE_ID, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_STUDY_ROLE_ID); String userName = params.get(REQUEST_PARAM_USER_NAME); String siteId = params.get(REQUEST_PARAM_SITE_ID); String studyId = params.get(REQUEST_PARAM_STUDY_ID); String studyRoleId = params.get(REQUEST_PARAM_STUDY_ROLE_ID); List<SitePolicy> sitePolicy = new ArrayList<SitePolicy>(); if ((siteId != null) && (userName != null)) { return sitePolicyRepository .findBySiteIdAndUserName(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, siteId), userName); } else if (userName != null) { return sitePolicyRepository.findByUserName(userName); } else if (studyId != null) { return sitePolicyRepository .findByStudyRoleStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId)); } else if (studyRoleId != null) { return sitePolicyRepository .findByStudyRoleRoleId(validateIntegerParameter(REQUEST_PARAM_STUDY_ROLE_ID, studyRoleId)); } else {//from w w w . ja v a 2s .c o m Iterator iter = sitePolicyRepository.findAll().iterator(); CollectionUtils.addAll(sitePolicy, iter); return sitePolicy; } }
From source file:edu.isi.misd.scanner.network.registry.web.controller.StudyRoleController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<StudyRole> getStudyRoles(@RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_SITE_ID, REQUEST_PARAM_USER_NAME);/*from w w w . j a va 2 s. c o m*/ String studyId = params.get(REQUEST_PARAM_STUDY_ID); String siteId = params.get(REQUEST_PARAM_SITE_ID); String userName = params.get(REQUEST_PARAM_USER_NAME); if ((studyId != null) && (userName != null)) { return studyRoleRepository.findByStudyStudyIdAndScannerUsersUserName( validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), userName); } else if (studyId != null) { return studyRoleRepository .findByStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId)); } else if (siteId != null) { return studyRoleRepository.findByStudyStudyRequestedSitesSiteSiteId( validateIntegerParameter(REQUEST_PARAM_SITE_ID, siteId)); } else if (userName != null) { return studyRoleRepository.findByScannerUsersUserName(userName); } else { List<StudyRole> roles = new ArrayList<StudyRole>(); Iterator iter = studyRoleRepository.findAll().iterator(); CollectionUtils.addAll(roles, iter); return roles; } }
From source file:eionet.gdem.web.struts.stylesheet.EditStylesheetFormAction.java
@Override public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { ActionMessages errors = new ActionMessages(); StylesheetForm form = (StylesheetForm) actionForm; String stylesheetId = httpServletRequest.getParameter("stylesheetId"); if (stylesheetId == null || stylesheetId.equals("")) { stylesheetId = (String) httpServletRequest.getAttribute("stylesheetId"); }//from www . ja va 2s .c o m ConvTypeHolder ctHolder = new ConvTypeHolder(); StylesheetManager stylesheetManager = new StylesheetManager(); try { Stylesheet stylesheet = stylesheetManager.getStylesheet(stylesheetId); if (stylesheet == null) { try { httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND); } catch (IOException ex) { LOGGER.error("Failed to set 404 response status", ex); } return actionMapping.findForward(null); } form.setDescription(stylesheet.getDescription()); form.setOutputtype(stylesheet.getType()); form.setStylesheetId(stylesheet.getConvId()); form.setXsl(stylesheet.getXsl()); form.setXslContent(stylesheet.getXslContent()); form.setXslFileName(stylesheet.getXslFileName()); form.setModified(stylesheet.getModified()); form.setChecksum(stylesheet.getChecksum()); form.setSchemas(stylesheet.getSchemas()); // set empty string if dependsOn is null to avoid struts error in define tag: // Define tag cannot set a null value form.setDependsOn(stylesheet.getDependsOn() == null ? "" : stylesheet.getDependsOn()); if (stylesheet.getSchemas().size() > 0) { //set first schema for Run Conversion link form.setSchema(stylesheet.getSchemas().get(0).getSchema()); // check if any related schema has type=EXCEL, if yes, then depends on info should be visible List<Schema> relatedSchemas = new ArrayList<Schema>(stylesheet.getSchemas()); CollectionUtils.filter(relatedSchemas, new BeanPredicate("schemaLang", new EqualPredicate("EXCEL"))); if (relatedSchemas.size() > 0) { form.setShowDependsOnInfo(true); List<Stylesheet> existingStylesheets = new ArrayList<Stylesheet>(); for (Schema relatedSchema : relatedSchemas) { CollectionUtils.addAll(existingStylesheets, stylesheetManager .getSchemaStylesheets(relatedSchema.getId(), stylesheetId).toArray()); } form.setExistingStylesheets(existingStylesheets); } } ctHolder = stylesheetManager.getConvTypes(); /** FIXME - do we need the list of DD XML Schemas on the page StylesheetListHolder stylesheetList = StylesheetListLoader.getGeneratedList(httpServletRequest); List<Schema> schemas = stylesheetList.getDdStylesheets(); httpServletRequest.setAttribute("stylesheet.DDSchemas", schemas); */ /* String schemaId = schema.getSchemaId(stylesheet.getSchema()); if (!Utils.isNullStr(schemaId)) { httpServletRequest.setAttribute("schemaInfo", schema.getSchema(schemaId)); httpServletRequest.setAttribute("existingStylesheets", stylesheetManager.getSchemaStylesheets(schemaId, stylesheetId)); } */ //httpServletRequest.setAttribute(StylesheetListLoader.STYLESHEET_LIST_ATTR, StylesheetListLoader.getStylesheetList(httpServletRequest)); } catch (DCMException e) { e.printStackTrace(); LOGGER.error("Edit stylesheet error", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(e.getErrorCode())); saveErrors(httpServletRequest, errors); } //TODO why is it needed to update session attribute in each request httpServletRequest.getSession().setAttribute("stylesheet.outputtype", ctHolder); return actionMapping.findForward("success"); }
From source file:edu.isi.misd.scanner.network.registry.web.controller.ToolLibraryController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<ToolLibrary> getToolLibraries(@RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_DATASET_ID);//from ww w . ja va2 s . com if (!params.isEmpty()) { ArrayList<String> missingParams = new ArrayList<String>(); String userName = params.get(REQUEST_PARAM_USER_NAME); if (userName == null) { missingParams.add(REQUEST_PARAM_USER_NAME); } String studyId = params.get(REQUEST_PARAM_STUDY_ID); if (studyId == null) { missingParams.add(REQUEST_PARAM_STUDY_ID); } String dataSetId = params.get(REQUEST_PARAM_DATASET_ID); if (dataSetId == null) { missingParams.add(REQUEST_PARAM_DATASET_ID); } if (!missingParams.isEmpty()) { throw new BadRequestException("Required parameter(s) missing: " + missingParams); } return toolLibraryRepository.findToolLibraryByStudyPolicyStatement(userName, validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), validateIntegerParameter(REQUEST_PARAM_DATASET_ID, dataSetId)); } List<ToolLibrary> toolLibraries = new ArrayList<ToolLibrary>(); Iterator iter = toolLibraryRepository.findAll().iterator(); CollectionUtils.addAll(toolLibraries, iter); return toolLibraries; }
From source file:edu.isi.misd.scanner.network.registry.web.controller.StudyManagementPolicyController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<StudyManagementPolicy> getStudyManagementPolicies( @RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_STUDY_ROLE_ID, REQUEST_PARAM_USER_NAME); String studyId = params.get(REQUEST_PARAM_STUDY_ID); String studyRoleId = params.get(REQUEST_PARAM_STUDY_ROLE_ID); String userName = params.get(REQUEST_PARAM_USER_NAME); if ((studyId != null) && (userName != null)) { return studyManagementPolicyRepository.findByStudyStudyIdAndStudyRoleScannerUsersUserName( validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), userName); } else if (userName != null) { return studyManagementPolicyRepository.findByStudyRoleScannerUsersUserName(userName); } else if (studyId != null) { return studyManagementPolicyRepository .findByStudyStudyId(validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId)); } else if (studyRoleId != null) { return studyManagementPolicyRepository .findByStudyRoleRoleId(validateIntegerParameter(REQUEST_PARAM_STUDY_ROLE_ID, studyRoleId)); } else {//from www . j a v a 2 s.co m List<StudyManagementPolicy> studyManagementPolicy = new ArrayList<StudyManagementPolicy>(); Iterator iter = studyManagementPolicyRepository.findAll().iterator(); CollectionUtils.addAll(studyManagementPolicy, iter); return studyManagementPolicy; } }
From source file:edu.isi.misd.scanner.network.registry.web.controller.AnalysisPolicyStatementController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<AnalysisPolicyStatement> getAnalysisPolicyStatements( @RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME, REQUEST_PARAM_INSTANCE_ID, REQUEST_PARAM_ANALYSIS_TOOL_ID); if (!params.isEmpty()) { ArrayList<String> missingParams = new ArrayList<String>(); String userName = params.get(REQUEST_PARAM_USER_NAME); if (userName == null) { missingParams.add(REQUEST_PARAM_USER_NAME); }//w ww . ja v a2s .c om String instanceId = params.get(REQUEST_PARAM_INSTANCE_ID); if (instanceId == null) { missingParams.add(REQUEST_PARAM_INSTANCE_ID); } String toolId = params.get(REQUEST_PARAM_ANALYSIS_TOOL_ID); if (toolId == null) { missingParams.add(REQUEST_PARAM_ANALYSIS_TOOL_ID); } if (!missingParams.isEmpty()) { throw new BadRequestException("Required parameter(s) missing: " + missingParams); } return analysisPolicyStatementRepository.findAnalysisPolicyStatementByUserNameAndInstanceIdAndToolId( userName, validateIntegerParameter(REQUEST_PARAM_INSTANCE_ID, instanceId), validateIntegerParameter(REQUEST_PARAM_ANALYSIS_TOOL_ID, toolId)); } List<AnalysisPolicyStatement> analysisPolicyStatements = new ArrayList<AnalysisPolicyStatement>(); Iterator iter = analysisPolicyStatementRepository.findAll().iterator(); CollectionUtils.addAll(analysisPolicyStatements, iter); return analysisPolicyStatements; }
From source file:com.cyclopsgroup.tornado.hibernate.HqlLargeList.java
/** * Overwrite or implement method getSize() * * @see com.cyclopsgroup.waterview.LargeList#getSize() *//*from w ww . j av a2s. c o m*/ public int getSize() throws Exception { String countQuery = "SELECT COUNT(*) " + hql; Session s = hibernate.getSession(dataSource); Query query = s.createQuery(countQuery); HashSet parameterNames = new HashSet(); CollectionUtils.addAll(parameterNames, query.getNamedParameters()); for (Iterator i = parameters.values().iterator(); i.hasNext();) { Parameter p = (Parameter) i.next(); if (parameterNames.contains(p.getName())) { query.setParameter(p.getName(), p.getValue(), p.getType()); } } List result = query.list(); if (result == null || result.isEmpty()) { return -1; } Integer i = (Integer) result.get(0); return i.intValue(); }
From source file:edu.isi.misd.scanner.network.registry.web.controller.AnalysisToolController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<AnalysisTool> getAnalysisTools(@RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_USER_NAME, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_DATASET_ID, REQUEST_PARAM_LIBRARY_ID); if (!params.isEmpty()) { ArrayList<String> missingParams = new ArrayList<String>(); String userName = params.get(REQUEST_PARAM_USER_NAME); if (userName == null) { missingParams.add(REQUEST_PARAM_USER_NAME); }/*w w w . j ava 2 s . co m*/ String studyId = params.get(REQUEST_PARAM_STUDY_ID); if (studyId == null) { missingParams.add(REQUEST_PARAM_STUDY_ID); } String dataSetId = params.get(REQUEST_PARAM_DATASET_ID); if (dataSetId == null) { missingParams.add(REQUEST_PARAM_DATASET_ID); } String libraryId = params.get(REQUEST_PARAM_LIBRARY_ID); if (libraryId == null) { missingParams.add(REQUEST_PARAM_LIBRARY_ID); } if (!missingParams.isEmpty()) { throw new BadRequestException("Required parameter(s) missing: " + missingParams); } return analysisToolRepository.findAnalysisToolByStudyPolicyStatement(userName, validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), validateIntegerParameter(REQUEST_PARAM_DATASET_ID, dataSetId), validateIntegerParameter(REQUEST_PARAM_LIBRARY_ID, libraryId)); } List<AnalysisTool> toolLibraries = new ArrayList<AnalysisTool>(); Iterator iter = analysisToolRepository.findAll().iterator(); CollectionUtils.addAll(toolLibraries, iter); return toolLibraries; }
From source file:edu.isi.misd.scanner.network.registry.web.controller.DataSetInstanceController.java
@RequestMapping(value = BASE_PATH, method = { RequestMethod.GET, RequestMethod.HEAD }, produces = HEADER_JSON_MEDIA_TYPE) public @ResponseBody List<DataSetInstance> getDataSetInstances(@RequestParam Map<String, String> paramMap) { Map<String, String> params = validateParameterMap(paramMap, REQUEST_PARAM_DATASET_ID, REQUEST_PARAM_STUDY_ID, REQUEST_PARAM_USER_NAME); if (!params.isEmpty()) { ArrayList<String> missingParams = new ArrayList<String>(); String dataSetId = params.get(REQUEST_PARAM_DATASET_ID); if (dataSetId == null) { missingParams.add(REQUEST_PARAM_DATASET_ID); }/*from www . java 2 s . c o m*/ String studyId = params.get(REQUEST_PARAM_STUDY_ID); if (studyId == null) { missingParams.add(REQUEST_PARAM_STUDY_ID); } String userName = params.get(REQUEST_PARAM_USER_NAME); if (userName != null) { if ((dataSetId != null) && (studyId != null)) { return dataSetInstanceRepository.findByDataSetIdAndStudyIdAndUserNameFilteredByAnalysisPolicy( validateIntegerParameter(REQUEST_PARAM_DATASET_ID, dataSetId), validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), userName); } else if (studyId != null) { return dataSetInstanceRepository.findByStudyIdAndUserNameFilteredByAnalysisPolicy( validateIntegerParameter(REQUEST_PARAM_STUDY_ID, studyId), userName); } else if ((dataSetId == null) && (studyId == null)) { return dataSetInstanceRepository .findByNodeSiteSitePoliciesStudyRoleUserRolesUserUserName(userName); } else { throw new BadRequestException("Required parameter(s) missing: " + missingParams); } } else { throw new BadRequestException("Required parameter missing: " + REQUEST_PARAM_USER_NAME); } } List<DataSetInstance> dataSetInstances = new ArrayList<DataSetInstance>(); Iterator iter = dataSetInstanceRepository.findAll().iterator(); CollectionUtils.addAll(dataSetInstances, iter); return dataSetInstances; }
From source file:gov.nih.nci.caintegrator.web.action.analysis.biodbnet.BioDbNetSearchAction.java
/** * Generates the search inputs in the following manner if case insensitivity has been selected. * - the original inputs//w w w .j ava 2s . c o m * - inputs are transformed to all upper case * - inputs are transformed to all lower case * - inputs are transformed to 1st letter upper case, all others lower case * @return the transformed input strings as comma separated values */ private Set<String> handleCaseSensitivity(SearchParameters searchParams) { Set<String> inputs = Sets.newTreeSet(); if (searchParams.isCaseSensitiveSearch() || searchParams.getSearchType() == SearchType.GENE_ID) { CollectionUtils.addAll(inputs, StringUtils.split(searchParams.getInputValues(), ',')); return inputs; } String[] splitInputs = StringUtils.split(searchParams.getInputValues(), ','); for (String input : splitInputs) { inputs.add(input); inputs.add(StringUtils.upperCase(input)); inputs.add(StringUtils.lowerCase(input)); inputs.add(StringUtils.capitalize(input)); } return inputs; }