List of usage examples for org.springframework.util StopWatch stop
public void stop() throws IllegalStateException
From source file:no.abmu.abmstatistikk.annualstatistic.webflow.HighSchoolLibraryValidator.java
public void validateAndSave(Object obj, Errors errors) { if (logger.isDebugEnabled()) { logger.debug("Executing validateAndSave"); }/*www .ja v a2 s. c o m*/ StopWatch stopWatch = new StopWatch(); stopWatch.start("validateAndSave"); SchemaReport schemaReport = webFlowService.webSchemaValuesToDataBaseSchema(this, (WebSchemaDefinition) obj); FolkeBibScreen folkeBibScreen = new FolkeBibScreen(schemaReport.getReport()); super.validate(folkeBibScreen, errors); // Has to be super or else endless loop. webFlowService.saveDataBaseSchemaIfNoError(folkeBibScreen, errors); stopWatch.stop(); logger.info("[validateAndSave] tok [" + stopWatch.getTotalTimeMillis() + "] ms"); }
From source file:no.abmu.abmstatistikk.web.ABMStatistikkCommentReportController.java
/** * Custom handler handleCommentReportPrimarySchoolExcelFile. * /*w w w. j a v a 2 s .c o m*/ * @param request current HTTP request * @param response current HTTP response * @return a ModelAndView to render the response * @throws ServletException */ public ModelAndView handleCommentReportPrimarySchoolExcelFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info(" XXXXXXXXXXXXXXXXXXX createMAVOrganisationTypeAndSchemaToFile: START "); StopWatch stopWatch = new StopWatch(); stopWatch.start("handleCommentReportPrimarySchoolExcelFile"); // OrganisationType String organisationType = OrganisationTypeNameConst.PRIMARY_SCHOOL_LIBRARY; // Schema SchemaTypeNameAndVersion schemaTypeNameAndVersion = SchemaTypeNameAndVersion .newInstance(SchemaName.PRIMARY_SCHOOL_LIBRARY_STATISTIC, STATISTICAL_YEAR); // View String viewName = "grunnskoleBibCommentsReportXlsViewToFile"; ModelAndView mav = commentReportData(organisationType, schemaTypeNameAndVersion, viewName); stopWatch.stop(); logger.info("[private:handleCommentReportPrimarySchoolExcelFile] tok [" + stopWatch.getTotalTimeMillis() + "] ms"); logger.info(" XXXXXXXXXXXXXXXXXXX handleCommentReportPrimarySchoolExcelFile: STOP "); return mav; }
From source file:no.abmu.abmstatistikk.web.ABMStatistikkCommentReportController.java
/** * Custom handler handleCommentReportHighSchoolLibrariesExcelFile. * //from ww w . ja v a 2 s. co m * @param request current HTTP request * @param response current HTTP response * @return a ModelAndView to render the response * @throws ServletException */ public ModelAndView handleCommentReportHighSchoolLibrariesExcelFile(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.info(" XXXXXXXXXXXXXXXXXXX handleCommentReportHighSchoolLibrariesExcelFile: START "); StopWatch stopWatch = new StopWatch(); stopWatch.start("handleCommentReportHighSchoolLibrariesExcelFile"); // OrganisationType String organisationType = OrganisationTypeNameConst.HIGH_SCHOOL_LIBRARY; // Schema SchemaTypeNameAndVersion schemaTypeNameAndVersion = SchemaTypeNameAndVersion .newInstance(SchemaName.HIGH_SCHOOL_LIBRARY_STATISTIC, STATISTICAL_YEAR); // View String viewName = "vgsBibCommentsReportXlsViewToFile"; ModelAndView mav = commentReportData(organisationType, schemaTypeNameAndVersion, viewName); stopWatch.stop(); logger.info("[private:handleCommentReportHighSchoolLibrariesExcelFile] tok [" + stopWatch.getTotalTimeMillis() + "] ms"); logger.info(" XXXXXXXXXXXXXXXXXXX handleCommentReportHighSchoolLibrariesExcelFile: FINISH "); return mav; }
From source file:no.abmu.abmstatistikk.web.AbstractOrganisationBrowsingController.java
/** * Browse by county.//w ww .j a v a 2 s . co m * * @param request current HTTP request * @param attribute in current HttpSession * @param organisationTypeName name on organisationType to browse * @param viewName name of the View to render, to be resolved * by the DispatcherServlet's ViewResolver * @return ModelAndView holder for both Model and View in * the web MVC framework to be resolved by a DispatcherServlet. */ protected ModelAndView browseOrgTypeByCounty(HttpServletRequest request, String attribute, String organisationTypeName, String viewName) { /* * This should be replaced with AOP in an XML spring config-file. */ if (!isSecureContext()) { logger.error("[browseOrgTypeByCounty]: no securityService, logg off."); return new ModelAndView(ViewNameConst.LOGOFF_VIEW); } StopWatch stopWatch = new StopWatch("browseOrgType"); stopWatch.start("Mav_for_browsing_organisationType_by_county"); Integer countynumber = getCountyNumberFromRequestOrLoggedOnUser(request); if (null == countynumber || countynumber.intValue() == 0) { logger.error("[browseOrgTypeByCounty]: no countynumber"); return new ModelAndView(ViewNameConst.REDIRECT_2_MAIN_MENU); } OrgUnitFinderSpecificationBean finderBean = new OrgUnitFinderSpecificationBean(); finderBean.setOrganisationTypeName(organisationTypeName); finderBean.setCountyNumber(countynumber); finderBean.setTodayAsActiveDate(); ModelAndView mav = browse(request, attribute, finderBean, viewName); stopWatch.stop(); logger.info("Getting ModelAndview for organisationType " + organisationTypeName + " for county " + countynumber + " tok " + stopWatch.getTotalTimeMillis() + " milliseconds."); return mav; }
From source file:no.abmu.abmstatistikk.web.AbstractReportController.java
protected ModelAndView createMAVForOrganisationUnit(HttpServletRequest request, String view, SchemaTypeNameAndVersion schemaTypeNameAndVersion) { Assert.checkRequiredArgument("request", request); Assert.checkRequiredArgument("view", view); Assert.checkRequiredArgument("schemaTypeAndName", schemaTypeNameAndVersion); StopWatch stopWatch = new StopWatch(); stopWatch.start("private_createMAVForOrganisationUnit"); if (noLoggedOnStatusInfo(request)) { logger.error("No loggedOnStatus exists, logout."); return new ModelAndView(ViewNameConst.LOGOFF_VIEW); }/*from www .j a va 2s . c o m*/ Long workingSchemaOrgUnitId = changeWorkingSchemaOrgUnitIdOrGetCurrent(request); if (workingSchemaOrgUnitId == null) { logger.error("No workingSchemaOrgUnitId or LoggedOnOrgUnitId exists, log off"); return new ModelAndView(ViewNameConst.LOGOFF_VIEW); } // String schemaVersion = Integer.toString(reportPeriod); OrgUnitFinderSpecificationBean finderBean = new OrgUnitFinderSpecificationBean(); finderBean.setOrganisationUnitId(workingSchemaOrgUnitId); SchemaList jasperReportDataSource = reportService.createFullReportData(finderBean, schemaTypeNameAndVersion); if (schemaTypeNameAndVersion.getYear() >= 2009 && schemaTypeNameAndVersion.getSchemaName().equals(SchemaName.KUD_CULTURAL_ACTIVITY_REPORT)) { int reportPeriod = schemaTypeNameAndVersion.getYear(); int oneYearBack = reportPeriod - 1; String prefixOneYearBack = "LastYear"; SchemaTypeNameAndVersion kudActivitySchemaAndVersionOneYearBack = SchemaTypeNameAndVersion .newInstance(SchemaName.KUD_CULTURAL_ACTIVITY_REPORT, oneYearBack); reportService.getReportDataForOrganisationUnits(jasperReportDataSource, kudActivitySchemaAndVersionOneYearBack, prefixOneYearBack); int twoYearBack = reportPeriod - 2; String prefixTwoYearBack = "YearBeforeLastYear"; SchemaTypeNameAndVersion kudActivitySchemaAndVersionTwoYearBack = SchemaTypeNameAndVersion .newInstance(SchemaName.KUD_CULTURAL_ACTIVITY_REPORT, twoYearBack); reportService.getReportDataForOrganisationUnits(jasperReportDataSource, kudActivitySchemaAndVersionTwoYearBack, prefixTwoYearBack); } SessionLocaleResolver sessionLocaleResolver = new SessionLocaleResolver(); SchemaPdfLogo pdfLogo = SchemaPdfLogo.newInstance(schemaTypeNameAndVersion); Locale locale = sessionLocaleResolver.resolveLocale(request); logger.info("We are using locale=[" + locale.toString() + "]"); int reportPeriod = schemaTypeNameAndVersion.getYear(); Map<String, Object> model = new HashMap<String, Object>(); model.put("logourl", pdfLogo.getLogoUrl()); model.put("logoheight", pdfLogo.getLogoHeight()); model.put("logowidth", pdfLogo.getLogoWidth()); model.put("reportData", jasperReportDataSource); model.put("abmstatistikk.reportPeriod", Integer.toString(reportPeriod)); model.put("abmstatistikk.budgetYear", Integer.toString(reportPeriod + 1)); model.put(JRParameter.REPORT_LOCALE, locale); ModelAndView mav = new ModelAndView(view, model); stopWatch.stop(); if (logger.isDebugEnabled()) { logger.debug("[private:createMAVForOrganisationUnit] tok[" + stopWatch.getTotalTimeMillis() + "] ms"); } return mav; }
From source file:no.abmu.abmstatistikk.web.AbstractReportController.java
protected ModelAndView basicReportDataByMuncipality(HttpServletRequest request, OrgUnitFinderSpecificationBean finderBean, SchemaTypeNameAndVersion schemaTypeNameAndVersion, String viewName) {/*from w w w . j a v a2 s .c o m*/ Assert.checkRequiredArgument("request", request); Assert.checkRequiredArgument("finderBean", finderBean); Assert.checkRequiredArgument("schemaTypeNameAndVersion", schemaTypeNameAndVersion); Assert.checkRequiredArgument("viewName", viewName); if (logger.isDebugEnabled()) { logger.debug("Executing: reportDataByMuncipality"); } /* * This should be replaced with AOP in an XML spring config-file. */ if (!isSecureContext()) { logger.error("[reportDataByMuncipality]: no secureContext loging off"); return new ModelAndView(ViewNameConst.LOGOFF_VIEW); } Integer municipalityNumber = getMuncipalityNumberFromRequestOrLoggedOnUser(request); if (null == municipalityNumber) { logger.error("[reportDataByMuncipality]: could not get any municipality number, return to mainmenu."); return new ModelAndView(ViewNameConst.REDIRECT_2_MAIN_MENU); } StopWatch stopWatch = new StopWatch(); stopWatch.start("private_createByMuncipalityReportData"); finderBean.setMuncipalityNumber(municipalityNumber); SchemaList jasperReportDataSource = reportService.createBasicReportData(finderBean, schemaTypeNameAndVersion); Map<String, Object> model = getModel(jasperReportDataSource); model.put("abmstatistikk.reportPeriod", schemaTypeNameAndVersion.getVersion()); ModelAndView mav = new ModelAndView(viewName, model); stopWatch.stop(); logger.info("[private:createByMuncipalityReportData] tok[" + stopWatch.getTotalTimeMillis() + "] ms"); return mav; }
From source file:no.abmu.abmstatistikk.web.AbstractStatusBrowsingController.java
/** * Refreshable status browser./*from w ww .j a v a 2 s. c om*/ * @param request current HTTP request * @param attribute to use store RefreshablePageholder in current http session * @param organisationType name of organisation type * @param schemaType name of schema type * @param view - if sucess use this view as view in ModelAndView * @param year - report year * @return a ModelAndView to render the response */ protected ModelAndView statusBrowser(HttpServletRequest request, String attribute, OrgUnitFinderSpecificationBean finderBean, SchemaTypeNameAndVersion schemaTypeNameAndVersion, String view) { logger.info("Executing statusBrowser on organisationType='" + finderBean.getOrganisationTypeName() + "' and schemaType='" + schemaTypeNameAndVersion.toString() + "'"); StopWatch stopWatch = new StopWatch("browseOrgType"); /* * This should be replaced with AOP in an XML spring config-file. */ if (!isSecureContext()) { return new ModelAndView(ViewNameConst.LOGOFF_VIEW); } stopWatch.start("Mav_for_browsing_organisationType"); Map model = statusBrowse(request, attribute, finderBean, schemaTypeNameAndVersion); stopWatch.stop(); logger.info("Getting ModelAndview for organisationType " + finderBean.getOrganisationTypeName() + " tok " + stopWatch.getTotalTimeMillis() + " milliseconds."); return new ModelAndView(view, model); }
From source file:no.abmu.common.jasperreports.JasperReportsXlsViewToFile.java
/** * Perform rendering for a single Jasper Reports exporter, that is, * for a pre-defined output format.//from w w w . j a v a2 s. co m */ protected void renderReport(JasperPrint populatedReport, Map model, HttpServletResponse response) throws Exception { log.info(" XXXXXXXXXXXXXXXXXXX renderReport: START "); StopWatch stopWatch = new StopWatch(); stopWatch.start("renderReport"); // Prepare report for rendering. JRExporter exporter = createExporter(); if (getConvertedExporterParameters() != null) { exporter.setParameters(getConvertedExporterParameters()); } // We need to write binary output to the response OutputStream. // Render report into local OutputStream. // IE workaround: write into byte array first. ByteArrayOutputStream baos = new ByteArrayOutputStream(OUTPUT_BYTE_ARRAY_INITIAL_SIZE); JasperReportsUtils.render(exporter, populatedReport, baos); // Flush byte array to servlet output stream. java.io.FileOutputStream fileOutputStream = new FileOutputStream(getOutPutFileName()); baos.writeTo(fileOutputStream); fileOutputStream.flush(); fileOutputStream.close(); stopWatch.stop(); log.info("[private:renderReport] tok[" + stopWatch.getTotalTimeMillis() + "] ms"); log.info(" XXXXXXXXXXXXXXXXXXX renderReport: FINISH "); }
From source file:no.abmu.finances.service.hibernate3.FinanceServiceHelperH3Impl.java
public ReportStatus[] getReportStatusBySchemaTypeAndVersion( List<OrganisationUnitForBrowsing> orgUnitsForBrodwsing, String schemaTypeName, String version) { StopWatch stopWatch = new StopWatch(); stopWatch.start();/*from w w w .jav a 2 s. co m*/ String finishFieldNumber = getFinishFieldNumberForSchemaTypeAndVersion(schemaTypeName, version); List<ReportStatus> reportStatusAsList = new ArrayList<ReportStatus>(); for (OrganisationUnitForBrowsing orgForBrowse : orgUnitsForBrodwsing) { ReportDataH3FinderSpecification finderSpecification = new ReportDataH3FinderSpecification( schemaTypeName, version, orgForBrowse.getOrganisationUnitId()); MainReportData reportData = (MainReportData) financeService.findSingle(finderSpecification); reportStatusAsList.add(createReportStatus(orgForBrowse, reportData, finishFieldNumber)); } stopWatch.stop(); logger.info("Finish prosessing of reportStatus for schemaType:" + schemaTypeName + " with " + orgUnitsForBrodwsing.size() + " elements in " + stopWatch.getTotalTimeMillis() + " ms"); return reportStatusAsList.toArray(new ReportStatus[reportStatusAsList.size()]); }
From source file:no.abmu.lise.service.AbstractLiseImportService.java
private boolean checkOrganisationUnits(OrganisationRegisterBaseService baseService, ExcelParser excelParser, Map<String, String> excelColumnNames, boolean printWarningMessage) { StopWatch stopWatch = new StopWatch(); stopWatch.start();/*from w w w.j a v a2 s . co m*/ int rowsWithOutMatch = 0; int numOfRowsWithData = excelParser.countNumberOfRowsInSheetBeforeStopTag(); // Get organisationUnit column name String organisationUnitExcelColumnName = excelColumnNames .get(DataLoaderUtils.KEY_ORGANISATIONUNIT_NAME_EXCEL_COLUMN); // First get a unique set of organisationUnit names Set<String> organisationUnitNames = new LinkedHashSet<String>(); Set<String> foundOrganisationUnitNames = new LinkedHashSet<String>(); Set<String> notFoundOrganisationUnitNames = new LinkedHashSet<String>(); excelParser.load(); for (; excelParser.hasNext(); excelParser.next()) { String orgUnitName = excelParser.getCellValueAsString(organisationUnitExcelColumnName); organisationUnitNames.add(orgUnitName); OrganisationUnit organisationUnit = DataLoaderUtils.checkForAndGetOneAndOnlyOneOrganisationUnit( excelParser, baseService, excelColumnNames, printWarningMessage); if (organisationUnit != null) { foundOrganisationUnitNames.add(orgUnitName); } else { notFoundOrganisationUnitNames.add(orgUnitName); rowsWithOutMatch++; } } // Report result in log. String resultToLog = "The processed excel sheet had " + numOfRowsWithData + " rows with " + organisationUnitNames.size() + " distinkt organisationUnitNames, of which " + foundOrganisationUnitNames.size() + " have exact match, and " + notFoundOrganisationUnitNames.size() + " do not have exact match. We have " + rowsWithOutMatch + " rows without match."; logger.info(resultToLog); // System.out.println(resultToLog); stopWatch.stop(); String timeMessage = "Testing for organisationUnit matches tok " + stopWatch.getTotalTimeMillis() + " ms."; logger.info(timeMessage); // System.out.println(timeMessage); return (rowsWithOutMatch == 0); }