List of usage examples for org.springframework.util StopWatch start
public void start(String taskName) throws IllegalStateException
From source file:ro.cs.cm.ws.client.ts.TSWebServiceClient.java
/** * Open the project details/*from w w w . ja v a 2 s. c om*/ * * @author Adelina * * @param projectId * @throws XmlMappingException * @throws IOException * @throws WSClientException * @throws BusinessException */ public void openProjectDetails(Integer projectId) throws XmlMappingException, IOException, WSClientException, BusinessException { logger.debug("openProjectDetails START"); StopWatch sw = new StopWatch(); sw.start("openProjectDetails"); try { //create the bean marshalled into the request GetProjectIdForOpenRequest getProjectIdForOpenRequest = new GetProjectIdForOpenRequest(); getProjectIdForOpenRequest.setProjectId(projectId); // unmarshall the response Project project = BLProject.getInstance().getWithStatus(projectId); if (project != null) { if (project.getStatus() == IConstant.NOM_PROJECT_STATUS_OPENED) { getWebServiceTemplate().marshalSendAndReceive(getProjectIdForOpenRequest); } } } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<TSEndpointExceptionBean> endpointException = (JAXBElement<TSEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("openProjectDetails END"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.cm.ws.client.ts.TSWebServiceClient.java
/** * Deletes the team member detail//from ww w .j a v a2s. co m * * @author Adelina * * @param memberId * @throws XmlMappingException * @throws IOException * @throws WSClientException * @throws BusinessException */ public void deleteTeamMemberDetails(Integer memberId) throws XmlMappingException, IOException, WSClientException, BusinessException { logger.debug("deleteTeamMemberDetails START"); StopWatch sw = new StopWatch(); sw.start("deleteTeamMemberDetails"); try { //create the bean marshalled into the request GetTeamMemberIdForDeleteRequest getTeamMemberIdForDeleteRequest = new GetTeamMemberIdForDeleteRequest(); getTeamMemberIdForDeleteRequest.setTeamMemberId(memberId); // unmarshall the response TeamMember teamMember = BLTeamMember.getInstance().getSimpleByMemberId(memberId); if (teamMember == null) { getWebServiceTemplate().marshalSendAndReceive(getTeamMemberIdForDeleteRequest); } } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<TSEndpointExceptionBean> endpointException = (JAXBElement<TSEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(endpointException.getValue().getCode(), endpointException.getValue().getMessage(), soapFault); } } logger.debug("deleteTeamMemberDetails END"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.logaudit.web.servlet.ReportServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.debug("doPost START"); ServletOutputStream sos = null;/*from w ww.jav a 2 s . c om*/ StopWatch sw = new StopWatch(); sw.start("Retrieve report"); try { //create the bean containing the report parameters which will be passed to the Report Web Service Client AuditEventsReportParams reportParams = new AuditEventsReportParams(); //Retrieve the start date param for the report request SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm"); Date startDate = sdf.parse(ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_START_DATE_PARAM), new ParsePosition(0)); if (startDate != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_START_DATE_PARAM, startDate); } //Retrieve the end date param for the report request Date endDate = sdf.parse(ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_END_DATE_PARAM), new ParsePosition(0)); if (endDate != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_END_DATE_PARAM, endDate); } //Retrieve the personId param for the report request String personId = ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_PERSON_ID_PARAM); if (personId != null && personId != "") { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_PERSON_ID_PARAM, Integer.valueOf(personId)); } //Retrieve the message param for the report request String message = ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MESSAGE_PARAM); if (message != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MESSAGE_PARAM, message); } //Retrieve the event param for the report request String event = ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_EVENT_PARAM); if (event != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_EVENT_PARAM, event); } //Retrieve the moduleId param for the report request Integer moduleId = ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM); if (moduleId != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM, moduleId); } //Retrieve the reportTitle param for the report request String reportTitle = ServletRequestUtils.getStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_PARAM_REPORT_TITLE); if (reportTitle != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_PARAM_REPORT_TITLE, reportTitle); } //Retrieve the orientation param for the report request String orientation = ServletRequestUtils.getRequiredStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_ORIENTATION_PARAM); if (orientation != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_ORIENTATION_PARAM, orientation); } //Retrieve the report format param for the report request String format = ServletRequestUtils.getRequiredStringParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_FORMAT_PARAM); if (format != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_FORMAT_PARAM, format.toLowerCase()); } //Retrieve the organisationId param for the report request Integer organisationId = ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_ORGANISATION_ID_PARAM); if (organisationId != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_ORGANISATION_ID_PARAM, organisationId); } reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_LOCALE_PARAM, request.getSession().getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME) .toString().toLowerCase().substring(0, 2)); //if the attachment param exists on the request, it means that the generated report must be a whole html page with head and body tags, //otherwise the report must be embeddable in an existent html page(no head and body tags) if (ServletRequestUtils.getBooleanParameters(request, ATTACHMENT) != null) { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_HTML_IS_EMBEDDABLE, false); } else { reportParams.setProperty(IReportsWsClientConstant.AUDIT_EVENTS_REPORT_HTML_IS_EMBEDDABLE, true); } //Servlet's OutputStream sos = response.getOutputStream(); //get the requested report DataHandler reportFileReceived = ReportsWebServiceClient.getInstance() .getAuditEventsReport(reportParams); //set the response content type if (format.toLowerCase().equals("html")) { response.setContentType("text/html"); if (ServletRequestUtils.getBooleanParameters(request, ATTACHMENT) != null) { response.setHeader("Content-Disposition", "attachment; filename=\"".concat(reportTitle).concat(".html\"")); } else { response.setHeader("Content-Disposition", "inline; filename=\"".concat(reportTitle).concat(".html\"")); } } else if (format.toLowerCase().equals("pdf")) { response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "inline; filename=\"".concat(reportTitle).concat(".pdf\"")); } else if (format.toLowerCase().equals("doc")) { response.setContentType("application/msword"); response.setHeader("Content-Disposition", "attachment; filename=\"".concat(reportTitle).concat(".doc\"")); } else if (format.toLowerCase().equals("xls")) { response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=\"".concat(reportTitle).concat(".xls\"")); } //write the received report bytes stream to response output stream byte buffer[] = new byte[4096]; BufferedInputStream bis = new BufferedInputStream(reportFileReceived.getInputStream()); int size = 0; int i; while ((i = bis.read(buffer, 0, 4096)) != -1) { sos.write(buffer, 0, i); size += i; } if (size == 0) { response.setContentType("text/plain"); sos.write("No content !".getBytes()); } bis.close(); response.setContentLength(size); logger.debug("**** report transfer completed !"); } catch (Exception ex) { logger.error("", ex); response.setContentType("text/html"); String exceptionCode = null; ; if (((Integer) ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM)) .equals(new Integer(IConstant.NOM_MODULE_OM_LABEL_KEY))) { exceptionCode = ICodeException.AUDITOM_REPORT_CREATE; } else if (((Integer) ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM)) .equals(new Integer(IConstant.NOM_MODULE_DM_LABEL_KEY))) { exceptionCode = ICodeException.AUDITDM_REPORT_CREATE; } else if (((Integer) ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM)) .equals(new Integer(IConstant.NOM_MODULE_CM_LABEL_KEY))) { exceptionCode = ICodeException.AUDITCM_REPORT_CREATE; } else if (((Integer) ServletRequestUtils.getIntParameter(request, IReportsWsClientConstant.AUDIT_EVENTS_REPORT_MODULE_ID_PARAM)) .equals(new Integer(IConstant.NOM_MODULE_TS_LABEL_KEY))) { exceptionCode = ICodeException.AUDITTS_REPORT_CREATE; } response.getWriter().write("<html xmlns=\"http://www.w3.org/1999/xhtml\">" + "<head> <script type=\"text/javascript\" src=\"js/cs/cs_common.js\"></script>" + "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/standard/css/style.css\"/> " + "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/standard/css/yui/fonts-min.css\" /> " + "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/standard/css/yui/container.css\" /> </head> " + "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/standard/css/yui/button.css\" />" + "<body> <div id=\"errorsContainer\" class=\"errorMessagesDiv\"> " + "<table class=\"errorMessagesTable\">" + "<tr>" + "<td>" + "</td>" + "<td>" + "<div class=\"hd\">" + "<div id=\"closeErrors\" class=\"messagesCloseButon\"></div>" + "</div>" + "</td>" + "</tr>" + "<tr>" + "<td>" + "<div class=\"bd\">" + "<div style=\"width:470px\"> " + messageSource.getMessage(CREATE_ERROR, new Object[] { exceptionCode, ControllerUtils.getInstance().getFormattedCurrentTime() }, (Locale) request.getSession() .getAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME)) + "<br/> " + "</div>" + "</div>" + "</td>" + "<td>" + "</td>" + "</tr>" + "</table>" + "<div class=\"ft\"> </div>" + "</div>" + "<script> " + "if(typeof(YAHOO.widget.Module) != \"undefined\") { " + "YAHOO.audit.errorsContainer = new YAHOO.widget.Module(\"errorsContainer\", {visible:true} ); " + "YAHOO.audit.errorsContainer.render() ;" + "YAHOO.audit.errorsContainer.show();" + "YAHOO.util.Event.addListener(\"closeErrors\", \"click\", function () { " + "YAHOO.audit.errorsContainer.hide();" + "YAHOO.audit.errorsContainer.destroy(); " + "}, YAHOO.audit.errorsContainer, true);" + "}" + "</script> </body></html>"); response.getWriter().flush(); } finally { if (sos != null) { //Flushing and Closing OutputStream sos.flush(); sos.close(); logger.debug("**** servlet output stream closed."); } } logger.debug("doPost END"); //list all the tasks performed logger.debug(sw.prettyPrint()); sw.stop(); }
From source file:ro.cs.logaudit.ws.client.om.OMWebServiceClient.java
public List<WSOrganisation> getAllOrganisations() throws XmlMappingException, IOException, WSClientException { logger.debug("getAllOrganisations START"); StopWatch sw = new StopWatch(); sw.start("getAllOrganisations"); List<WSOrganisation> allOrganisations = null; try {//from www . ja va 2s . c o m //create the bean marshalled into the request GetAllOrganisationsRequest getAllOrganisationsRequest = new GetAllOrganisationsRequest(); //unmarshall the response to an WSOrganisation bean GetAllOrganisationsResponse response = (GetAllOrganisationsResponse) getWebServiceTemplate() .marshalSendAndReceive(getAllOrganisationsRequest); allOrganisations = response.getOrganisations(); } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<OMEndpointExceptionBean> omEndpointExceptionBean = (JAXBElement<OMEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(omEndpointExceptionBean.getValue().getCode(), omEndpointExceptionBean.getValue().getMessage(), soapFault); } } logger.debug("getAllOrganisations END"); sw.stop(); logger.debug(sw.prettyPrint()); return allOrganisations; }
From source file:ro.cs.om.ws.client.dme.DMEWebServiceClient.java
/** * //w w w .j a v a2 s .c o m * Deleting the organisation's workspace * * @author mitziuro * @param organisationId * @throws Exception */ public void deleteWorkspace(Integer organisationId) throws Exception { logger.debug("START - deleteWorkspace"); StopWatch sw = new StopWatch(); sw.start("add"); getWebServiceTemplate().marshalSendAndReceive(objectFactory .createDeleteWorkpaceRequest(IConstant.DME_WORKSPACE_PREFIX.concat(organisationId.toString()))); logger.debug("END - deleteWorkspace"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.om.ws.client.dme.DMEWebServiceClient.java
/** * /*www. java 2 s. com*/ * Deleting the workspaces * * @author mitziuro * @param organisationId * @throws Exception */ public void deleteWorkspaces(List<Integer> organisationIds) throws Exception { logger.debug("START - deleteWorkspace"); StopWatch sw = new StopWatch(); sw.start("add"); ArrayList<String> workspaces = new ArrayList<String>(); for (Integer organisation : organisationIds) { workspaces.add(IConstant.DME_WORKSPACE_PREFIX.concat(String.valueOf(organisation))); } //set the workpspaces on the transport bean DMWorkspaces workspacesList = new DMWorkspaces(); workspacesList.setWorkspaces(workspaces); getWebServiceTemplate().marshalSendAndReceive(objectFactory.createDeleteWorkpacesRequest(workspacesList)); logger.debug("END - deleteWorkspace"); sw.stop(); logger.debug(sw.prettyPrint()); }
From source file:ro.cs.ts.ws.client.om.OMWebServiceClient.java
public WSLogo getLogo(int organizationId) throws BusinessException, XmlMappingException, IOException, ro.cs.ts.exception.WSClientException { logger.debug("getLogo START"); StopWatch sw = new StopWatch(); sw.start("getLogo"); WSLogo logo = null;/*from ww w . ja va 2s. com*/ try { //create the bean marshalled into the request GetLogoRequest getLogoRequest = new GetLogoRequest(); getLogoRequest.setOrganisationId(organizationId); //unmarshall the response to an OrganisationSimple bean GetLogoResponse jaxbLogo = (GetLogoResponse) getWebServiceTemplate() .marshalSendAndReceive(getLogoRequest); logger.debug( "-------------------------------------------------------------------------------------------------"); logger.debug(jaxbLogo); logger.debug( "-------------------------------------------------------------------------------------------------"); logo = jaxbLogo.getLogo(); } catch (SoapFaultClientException soapFault) { SoapFaultDetail soapFaultDetail = soapFault.getSoapFault().getFaultDetail(); //if the soap fault detail field is empty, it means another type of exception than EndpointException has been thrown if (soapFaultDetail == null) { throw new WSClientException(soapFault.getFaultCode().toString(), soapFault.getFaultStringOrReason(), soapFault); //soap fault detail field not empty means the Web Service has thrown an EndpointException } else { SoapFaultDetailElement soapFaultDetailElement = (SoapFaultDetailElement) soapFaultDetail .getDetailEntries().next(); //unmarshall the soap fault detail element to a WS specific bean named dmeEndpointExceptionBean JAXBElement<OMEndpointExceptionBean> omEndpointExceptionBean = (JAXBElement<OMEndpointExceptionBean>) getWebServiceTemplate() .getUnmarshaller().unmarshal(soapFaultDetailElement.getSource()); //throw a new WSClientException with the code and message of the DMEEndpointExceptionBean retrieved previously throw new WSClientException(omEndpointExceptionBean.getValue().getCode(), omEndpointExceptionBean.getValue().getMessage(), soapFault); } } logger.debug("getLogo END"); sw.stop(); logger.debug(sw.prettyPrint()); return logo; }
From source file:ubic.gemma.core.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Get information on the conditions to be searched. This is not part of the query for the results themselves, but * uses the database to get metadata/summaries about the analyses that will be used. Initializes the searchResult * value object. Later, values which are non-missing will be replaced with either 'non-significant' or 'significant' * results./*from w w w . j av a 2 s . co m*/ * * @param searchResult to be initialized * @return list of the resultSets that should be queried. */ private List<DiffExResultSetSummaryValueObject> addConditionsToSearchResultValueObject( DifferentialExpressionGenesConditionsValueObject searchResult) { StopWatch watch = new StopWatch("addConditionsToSearchResultValueObject"); watch.start("Add conditions to search result value object"); List<DiffExResultSetSummaryValueObject> usedResultSets = new LinkedList<>(); int i = 0; DifferentialExpressionSearchTaskImpl.log.info("Loading " + experimentGroupName + " experiments..."); // database hit: important that this be fast. Map<ExpressionExperimentDetailsValueObject, Collection<DifferentialExpressionAnalysisValueObject>> analyses = differentialExpressionAnalysisService .getAnalysesByExperiment(EntityUtils.getIds(experimentGroup)); experiment: for (ExpressionExperimentDetailsValueObject bas : analyses.keySet()) { Collection<DifferentialExpressionAnalysisValueObject> analysesForExperiment = this .filterAnalyses(analyses.get(bas)); if (analysesForExperiment.isEmpty()) { continue; } /* * There will often just be one analysis for the experiment. Exception would be when there is subsetting. */ for (DifferentialExpressionAnalysisValueObject analysis : analysesForExperiment) { List<DiffExResultSetSummaryValueObject> resultSets = this.filterResultSets(analysis); usedResultSets.addAll(resultSets); if (resultSets.isEmpty()) { DifferentialExpressionSearchTaskImpl.log.info("No resultSets usable for " + bas.getId()); } for (DiffExResultSetSummaryValueObject resultSet : resultSets) { // this is taken care of by the filterResultSets assert resultSet.getNumberOfDiffExpressedProbes() != null; // sanity check. assert resultSet.getExperimentalFactors().size() == 1; // interactions not okay ExperimentalFactorValueObject factor = resultSet.getExperimentalFactors().iterator().next(); Collection<FactorValueValueObject> factorValues = this.filterFactorValues(analysis, factor.getValues(), resultSet.getBaselineGroup().getId()); if (factorValues.isEmpty()) { /* * This can only happen if there is just a baseline factorvalue. Even for one-sided tests // * that // won't be the case. */ DifferentialExpressionSearchTaskImpl.log .warn("Nothing usable for resultSet=" + resultSet.getResultSetId()); continue; } for (FactorValueValueObject factorValue : factorValues) { Condition condition = searchResult.new Condition(bas, analysis, resultSet, factorValue); condition.setExperimentGroupName(experimentGroupName); /* * SANITY CHECKS these fields should be filled in. If not, we are going to skip the results. */ if (condition.getNumberDiffExpressedProbes() == -1) { DifferentialExpressionSearchTaskImpl.log .warn(bas + ": Error: No hit list sizes for resultSet with ID=" + resultSet.getResultSetId()); continue; } if (condition.getNumberOfProbesOnArray() == null || condition.getNumberDiffExpressedProbes() == null) { DifferentialExpressionSearchTaskImpl.log.error(bas + ": Error: Null counts for # diff ex probe or # probes on array, Skipping"); continue experiment; } else if (condition.getNumberOfProbesOnArray() < condition .getNumberDiffExpressedProbes()) { DifferentialExpressionSearchTaskImpl.log.error( bas + ": Error: More diff expressed probes than probes on array. Skipping."); continue experiment; } searchResult.addCondition(condition); i++; } } } } watch.stop(); if (watch.getTotalTimeMillis() > 100) { // This does not include getting the actual diff ex results. DifferentialExpressionSearchTaskImpl.log.info("Get information on conditions/analyses for " + i + " factorValues: " + watch.getTotalTimeMillis() + "ms"); } return usedResultSets; }
From source file:ubic.gemma.core.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Main processing: fetch diff ex results. * * @param resultSets to be searched// w w w. ja va 2 s . c om * @param geneIds to be searched * @param searchResult holds the results */ private void fetchDifferentialExpressionResults(List<DiffExResultSetSummaryValueObject> resultSets, List<Long> geneIds, DifferentialExpressionGenesConditionsValueObject searchResult) { StopWatch watch = new StopWatch("Process differential expression search"); watch.start("Fetch diff ex results"); // Main query for results; the main time sink. Map<Long, Map<Long, DiffExprGeneSearchResult>> resultSetToGeneResults = differentialExpressionResultService .findDiffExAnalysisResultIdsInResultSets(resultSets, geneIds); watch.stop(); Collection<DiffExprGeneSearchResult> aggregatedResults = this .aggregateAcrossResultSets(resultSetToGeneResults); watch.start("Fetch details for contrasts for " + aggregatedResults.size() + " results"); Map<Long, ContrastsValueObject> detailedResults = this.getDetailsForContrasts(aggregatedResults); this.processHits(searchResult, resultSetToGeneResults, resultSets, detailedResults); watch.stop(); DifferentialExpressionSearchTaskImpl.log.info("Diff ex search finished:\n" + watch.prettyPrint()); }
From source file:ubic.gemma.tasks.visualization.DifferentialExpressionSearchTaskImpl.java
/** * Get information on the conditions to be searched. This is not part of the query for the results themselves, but * uses the database to get metadata/summaries about the analyses that will be used. Initializes the searchResult * value object. Later, values which are non-missing will be replaced with either 'non-significant' or 'significant' * results.// w ww . j a v a 2 s . c o m * * @param searchResult to be initialized * @return lsit of the resultSets that should be queried. */ private List<ExpressionAnalysisResultSet> addConditionsToSearchResultValueObject( DifferentialExpressionGenesConditionsValueObject searchResult) { StopWatch watch = new StopWatch("addConditionsToSearchResultValueObject"); watch.start("Add conditions to search result value object"); List<ExpressionAnalysisResultSet> usedResultSets = new LinkedList<ExpressionAnalysisResultSet>(); int experimentGroupIndex = 0; int i = 0; for (Collection<ExpressionExperiment> experimentGroup : experimentGroups) { log.info("Loading " + experimentGroupNames.get(experimentGroupIndex) + " experiments..."); // database hit: important that this be fast. Map<BioAssaySet, Collection<DifferentialExpressionAnalysis>> analyses = differentialExpressionAnalysisService .getAnalyses(experimentGroup); experiment: for (BioAssaySet bas : analyses.keySet()) { if (!(bas instanceof ExpressionExperiment)) { log.warn("Subsets not supported yet (" + bas + "), skipping"); continue; } ExpressionExperiment experiment = (ExpressionExperiment) bas; Collection<DifferentialExpressionAnalysis> analysesForExperiment = filterAnalyses( analyses.get(experiment)); if (analysesForExperiment.isEmpty()) { continue; } for (DifferentialExpressionAnalysis analysis : analysesForExperiment) { List<ExpressionAnalysisResultSet> resultSets = filterResultSets(analysis.getResultSets()); usedResultSets.addAll(resultSets); if (resultSets.isEmpty()) { log.info("No resultSets usable for " + experiment.getShortName()); } for (ExpressionAnalysisResultSet resultSet : resultSets) { // this is taken care of by the filterResultSets assert resultSet.getHitListSizes() != null; assert resultSet.getExperimentalFactors().size() == 1; ExperimentalFactor factor = resultSet.getExperimentalFactors().iterator().next(); Collection<FactorValue> factorValues = filterFactorValues(factor.getFactorValues(), resultSet.getBaselineGroup().getId()); for (FactorValue factorValue : factorValues) { Condition condition = searchResult.new Condition(experiment, analysis, resultSet, factorValue); condition.setExperimentGroupName(experimentGroupNames.get(experimentGroupIndex)); condition.setExperimentGroupIndex(experimentGroupIndex); /* * SANITY CHECKS these fields should be filled in. If not, we are going to skip the results. */ if (condition.getNumberDiffExpressedProbes() == -1) { log.warn(bas + ": Error: No hit list sizes for resultSet with ID=" + resultSet.getId()); continue; } if (condition.getNumberOfProbesOnArray() == null || condition.getNumberDiffExpressedProbes() == null) { log.error(bas + ": Error: Null counts for # diff ex probe or # probes on array, Skipping"); continue experiment; } else if (condition.getNumberOfProbesOnArray() < condition .getNumberDiffExpressedProbes()) { log.error(bas + ": Error: More diff expressed probes than probes on array. Skipping."); continue experiment; } searchResult.addCondition(condition); i++; } } } } experimentGroupIndex++; } watch.stop(); if (watch.getTotalTimeMillis() > 100) { // This does not include getting the actual diff ex results. log.info("Get information on conditions/analyses for " + i + " factorValues: " + watch.getTotalTimeMillis() + "ms"); } return usedResultSets; }