@RequestMapping(value = "/UgeneMatrix", method = RequestMethod.POST) public String getUgeneMatrixObservations( @Valid @ModelAttribute("feMatrixForm") FEMatrixform feUgeneForm, BindingResult result, Model model) { if (result.hasErrors()) { return "UgeneMatrix"; } assert (jobSearchService != null); User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); assert (user != null); List<JobSearchParameter> searchParameters = new ArrayList<JobSearchParameter>(9); searchParameters.add( new JobSearchParameter( JobSearchConstants.CLASSPROPERTY.getSearchKey(), feUgeneForm.getClassProperty(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.CLASSTIME.getSearchKey(), feUgeneForm.getClassTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.STARTDATE.getSearchKey(), feUgeneForm.getStartDate(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.ENDDATE.getSearchKey(), feUgeneForm.getEndDate(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.STARTTIME.getSearchKey(), feUgeneForm.getStartTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.ENDTIME.getSearchKey(), feUgeneForm.getEndTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.NOCLASSPROPERTYFEATURE.getSearchKey(), feUgeneForm.getNoCPFeatures(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.UGENETYPE.getSearchKey(), feUgeneForm.getUgeneAlgorithm(), 1)); JobSearch jobSearch = new JobSearch(); jobSearch.setSearchBy(user.getId()); jobSearch.setSearchParameters(searchParameters); JobSearchDetails jobSearchDetails = new JobSearchDetails(); jobSearchDetails.setSearchOn(SearchOn.UGENEMATRIX.getSearchOn()); jobSearchDetails.setSearchType("UGENEMATRIX"); jobSearchDetails.setSearchParameters(jobSearch.getSearchParameters().get(0).getValue()); jobSearchDetails.setScriptType(SearchScript.UGENEMATRIX.getSearchScript()); jobSearchDetails.setScriptParameters(jobSearchService.getScriptParameters(jobSearch)); jobSearchService.searchJob(jobSearch, jobSearchDetails); return "redirect:/MySearch/"; }
@RequestMapping(value = "/DownloadUgeneReport/{id}", method = RequestMethod.GET) public void doDownload( @PathVariable("id") String reportID, HttpServletRequest request, HttpServletResponse response) throws IOException { String fileName = "feUgeneReport" + reportID + ".tar.gz"; String fullPath = jobSearchService.getAppDataDirectory() + File.separator + "ugene" + File.separator + "output" + File.separator + fileName; File downloadFile = new File(fullPath); FileInputStream inputStream = new FileInputStream(downloadFile); String mimeType = servletContext.getMimeType(fullPath); if (mimeType == null) { // set to binary type if MIME mapping not found mimeType = "application/octet-stream"; } response.setContentType(mimeType); response.setContentLength((int) downloadFile.length()); String headerKey = "Content-Disposition"; String headerValue = String.format("attachment; filename=\"%s\"", downloadFile.getName()); response.setHeader(headerKey, headerValue); OutputStream outStream = response.getOutputStream(); byte[] buffer = new byte[BUFFER_SIZE]; int bytesRead = -1; while ((bytesRead = inputStream.read(buffer)) != -1) { outStream.write(buffer, 0, bytesRead); } inputStream.close(); outStream.close(); }
@RequestMapping(value = "/ML-FLEX", method = RequestMethod.POST) public String getMlFlexObservations( @Valid @ModelAttribute("mlflexForm") FEMlFlexForm mlflexform, BindingResult result, Model model) { if (result.hasErrors()) { return "FEMLFlex"; } assert (jobSearchService != null); User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); assert (user != null); List<JobSearchParameter> searchParameters = new ArrayList<JobSearchParameter>(9); searchParameters.add( new JobSearchParameter( JobSearchConstants.CLASSPROPERTY.getSearchKey(), mlflexform.getClassProperty(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.CLASSIFIER.getSearchKey(), mlflexform.getClassificationAlgorithm(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.FOLDS.getSearchKey(), mlflexform.getFolds().toString(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.NoITERATIONS.getSearchKey(), mlflexform.getNumberOfIterations().toString(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.CLASSTIME.getSearchKey(), mlflexform.getClassTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.STARTDATE.getSearchKey(), mlflexform.getStartDate(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.ENDDATE.getSearchKey(), mlflexform.getEndDate(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.STARTTIME.getSearchKey(), mlflexform.getStartTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.ENDTIME.getSearchKey(), mlflexform.getEndTime(), 1)); searchParameters.add( new JobSearchParameter( JobSearchConstants.NOCLASSPROPERTYFEATURE.getSearchKey(), mlflexform.getNoCPFeatures(), 1)); JobSearch jobSearch = new JobSearch(); jobSearch.setSearchBy(user.getId()); jobSearch.setSearchParameters(searchParameters); JobSearchDetails jobSearchDetails = new JobSearchDetails(); jobSearchDetails.setSearchOn(SearchOn.FEMLFLEX.getSearchOn()); jobSearchDetails.setSearchType("FEMlFlex"); jobSearchDetails.setSearchParameters(jobSearch.getSearchParameters().get(0).getValue()); jobSearchDetails.setScriptType(SearchScript.FEMLFLEX.getSearchScript()); jobSearchDetails.setScriptParameters(jobSearchService.getScriptParameters(jobSearch)); jobSearchService.searchJob(jobSearch, jobSearchDetails); return "redirect:/MySearch/"; }