List of usage examples for org.springframework.util StopWatch getTotalTimeMillis
public long getTotalTimeMillis()
From source file:no.abmu.abmstatistikk.web.AbstractStatusBrowsingController.java
/** * Refreshable status browser.//from w w w . jav a2 s. com * @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./* w ww.jav a2 s. c o 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 .j av a 2 s.c o 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();// w w w. j a va2s. 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); }
From source file:no.abmu.lise.util.LiseImportExcelParser.java
/** * Check for necessary input values.//from w ww. j a va2 s.c o m * * Returns null if OK, else error message with description of missing * input values. * * @return - errorMessage equals Null if OK, else description of * missing input values. */ public String checkInputValues() { logger.info("Start testing for nessesary input values ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); String[] notNullNamesSheet1 = { SUPPLIER_NAME, CONSORTIUM_NAME, C_AGREEMENT_START_DATE, PRODUCT_NAME, // P_DESCRIPTION, C_CURRENCY, RelationCustomerProduct_NAME }; String[] notNullNamesSheet2 = { CONSORTIUM_NAME, C_AGREEMENT_START_DATE, SP_PAYMENT_YEAR, SP_PAYMENT_CURRENCY, SP_PAYMENT_AMOUNT }; String[] notNullNamesSheet3 = { PRODUCT_NAME, CUSTOMER_NAME, CUSTOMERPAYMENT_INVOICE_YEAR }; StringBuffer resBuffer = new StringBuffer(); checkSheetForNotNullNames("Sheet1", notNullNamesSheet1, resBuffer); checkSheetForNotNullNames("Sheet2", notNullNamesSheet2, resBuffer); checkSheetForNotNullNames("Sheet3", notNullNamesSheet3, resBuffer); String errorMessage = resBuffer.toString(); if (StringUtil.notEmpty(errorMessage)) { logger.error(errorMessage); } else { logger.info("All nessesary input values were present ..."); } stopWatch.stop(); logger.info("Testing nessesary input values took " + stopWatch.getTotalTimeMillis() + " ms."); return errorMessage; }
From source file:no.abmu.lise.util.LiseImportExcelParser.java
public boolean checkExistenceOfOrganisations() { logger.info("Executing checkExistenceOfOrganisations"); boolean missingOrganisations = false; Set<String> organisationNames = new HashSet<String>(); StopWatch stopWatch = new StopWatch(); stopWatch.start();/*from w ww . ja va2 s . co m*/ load(); for (; hasNext(); next()) { String name = getRelationCustomerProductname(); if (!organisationNames.contains(name)) { organisationNames.add(name); } String supplierName = getSupplierName(); if (!organisationNames.contains(supplierName)) { organisationNames.add(supplierName); } } setSheetName("Sheet3"); load(); for (; hasNext(); next()) { String name = getCustomerName(); if (!organisationNames.contains(name)) { organisationNames.add(name); } } logger.info("Found a total of (" + organisationNames.size() + ") organisationunits in the excel file ..."); StopWatch stopWatchGetOrgunits = new StopWatch(); stopWatchGetOrgunits.start(); Object[] allOrganisations = baseService.findAll(no.abmu.organisationregister.domain.OrganisationUnit.class); stopWatchGetOrgunits.stop(); logger.info("Getting '" + allOrganisations.length + "' OrganisationUnits from db took '" + stopWatchGetOrgunits.getTotalTimeMillis() + "' ms."); for (int i = 0; i < allOrganisations.length; i++) { OrganisationUnit organisationUnit = (OrganisationUnit) allOrganisations[i]; String name = organisationUnit.getName().getReference(); if (!organisationNames.contains(name)) { logger.error("NO OrganisationUnit is registered for (" + name + ") this should be registered !"); missingOrganisations = true; } } stopWatch.stop(); logger.info("Testing for existence of organisations took " + stopWatch.getTotalTimeMillis() + " ms."); return missingOrganisations; }
From source file:no.abmu.organisationregister.service.AbstractOrganisationUnitImportService.java
private boolean checkOrganisationUnits(ExcelParser excelParser, Map<String, String> excelColumnNames, boolean printWarningMessage) { StopWatch stopWatch = new StopWatch(); stopWatch.start();/*from w w w . j a v a 2s.c o 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. logger.info( "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."); stopWatch.stop(); logger.info("Testing for organisationUnit matches tok " + stopWatch.getTotalTimeMillis() + " ms."); return (rowsWithOutMatch == 0); }
From source file:no.abmu.organisationregister.service.hibernate3.OrganisationUnitServiceH3Impl.java
public SchemaList getReportData(OrgUnitFinderSpecificationBean finderBean) { SchemaList schemaList = new SchemaList(); StopWatch stopWatch = new StopWatch("getReportData"); stopWatch.start("Sok i DB"); OrgUnitReportFinderSpecification reportFinder = new OrgUnitReportFinderSpecification(finderBean); List<OrgUnitReportData> resultList = (List<OrgUnitReportData>) find(reportFinder); for (OrgUnitReportData orgUnitReportData : resultList) { Map<String, Object> reportDataMap = orgUnitReportData.getReportData(); schemaList.add(reportDataMap);// www .jav a 2s . c o m } Comparator comparator = new SortingFieldSchemaComparator("countyNumberAndNameSortingField"); schemaList.setComparator(comparator); schemaList.sort(); stopWatch.stop(); logger.info("Creating reportData new method tok " + stopWatch.getTotalTimeMillis() + " milliseconds and returned " + resultList.size() + " elements " + " and schemaList has " + schemaList.size() + " elements"); return schemaList; }
From source file:no.abmu.organisationregister.service.hibernate3.OrganisationUnitServiceH3Impl.java
private SchemaList reportDataForOrganisationUnits(OrganisationUnit[] organisationUnits) { SchemaList reportData = new SchemaList(); StopWatch stopWatch = new StopWatch("reportDataForOrganisationUnits"); stopWatch.start("Sok i DB"); OrganisationUnit organisationUnit;//from ww w . ja va 2 s . c om for (int i = 0; i < organisationUnits.length; i++) { organisationUnit = organisationUnits[i]; reportData.add(reportDataForOrganisationUnit(organisationUnit)); } stopWatch.stop(); logger.info("Creating reportData old method tok " + stopWatch.getTotalTimeMillis() + " milliseconds and number of OrgUnits input " + organisationUnits.length + " elements " + " and schemaList has " + reportData.size() + " elements"); return reportData; }
From source file:no.abmu.organisationregister.util.OrganisationUnitImportExcelParser.java
/** * Check for necessary input values.//from w ww . j a va2 s . c o m * * Returns null if OK, else error message with description of missing * input values. * * @return - errorMessage equals Null if OK, else description of * missing input values. */ public String checkInputValues() { logger.info("Start testing for nessesary input values ..."); StopWatch stopWatch = new StopWatch(); stopWatch.start(); String[] notNullNames = { ORG_TYPE, NAVN_BOKMAL }; // {ORG_TYPE, NAVN_BOKMAL, ADRESSE_POST, POSTNR, POST_STED}; String errorMessage = checkInputValues(notNullNames); if (errorMessage != null) { logger.error(errorMessage); } else { logger.info("All nessesary input values were present ..."); } stopWatch.stop(); logger.info("Testing nessesary input values tok " + stopWatch.getTotalTimeMillis() + " ms."); return errorMessage; }