Examples of CodeBlockTrace


Examples of org.jboss.dashboard.profiler.CodeBlockTrace

        if (targetDS == null) return;

        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        CodeBlockTrace trace = null;
        try {
            // Get the connection.
            conn = targetDS.getConnection();

            // Execute the query.
            lastExecutedStmt = createSQLStatament();
            trace = new SQLStatementTrace(lastExecutedStmt.getSQLSentence()).begin();
            trace.addRuntimeConstraint(new DataSetLoadConstraints(this));

            log.debug("Load data set from datasource=" + dataSource + " SQL=" + lastExecutedStmt.getSQLSentence());
            stmt = lastExecutedStmt.getPreparedStatement(conn);
            rs = stmt.executeQuery();

            // Get the properties definition.
            ResultSetMetaData meta = rs.getMetaData();
            int propsSize = meta.getColumnCount();
            SQLDataSet.this.setPropertySize(propsSize);
            for (int i = 0; i < propsSize; i++) {
                SQLDataProperty dp = createSQLProperty();
                String propId = StringUtils.isNotBlank(meta.getColumnLabel(i + 1)) ? meta.getColumnLabel(i + 1) : meta.getColumnName(i + 1);
                dp.setPropertyId(propId.toLowerCase());
//                dp.setPropertyId(meta.getColumnName(i + 1).toLowerCase());
                dp.setType(meta.getColumnType(i + 1));
                dp.setTableName(meta.getTableName(i + 1));
                dp.setColumnName(meta.getColumnName(i + 1));
                addProperty(dp, i);
            }

            // Get rows and populate the data set values.
            int index = 0;
            while (rs.next()) {
                Object[] row = new Object[propsSize];
                for (int i = 0; i < propsSize; i++) row[i] = rs.getObject(i + 1);
                SQLDataSet.this.addRowValues(row);

                // Check load constraints (every 10,000 rows)
                if (++index == 10000) {
                    trace.checkRuntimeConstraints();
                    index = 0;
                }
            }

            // Once we got the dataset initialized then calculate the domain for each property.
            for (int i = 0; i < properties.length; i++) {
                SQLDataProperty property = (SQLDataProperty) properties[i];
                property.calculateDomain();
            }
        }
        catch (Exception e) {
            if (lastExecutedStmt != null) {
                log.error("Error in load() SQLDataset. SQL = " + lastExecutedStmt.getSQLSentence(), e);
            }
            throw e;
        }
        finally {
            try {
                if (rs != null) rs.close();
            } catch (Exception e) {
                log.warn("Error closing ResultSet: ", e);
            }
            try {
                if (stmt != null) stmt.close();
            } catch (Exception e) {
                log.warn("Error closing PreparedStatement: ", e);
            }
            if (conn != null) {
                conn.close();
            }
            if (trace != null) {
                trace.end();
            }
        }
    }
View Full Code Here

Examples of org.jboss.dashboard.profiler.CodeBlockTrace

        if (targetDS == null) return;

        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        CodeBlockTrace trace = null;
        try {
            // Get the connection.
            conn = targetDS.getConnection();

            // Execute the query.
            lastExecutedStmt = createSQLStatament();
            trace = new SQLStatementTrace(lastExecutedStmt.getSQLSentence()).begin();
            log.debug("Load data set from datasource=" + dataSource + " SQL=" + lastExecutedStmt.getSQLSentence());
            stmt = lastExecutedStmt.getPreparedStatement(conn);
            rs = stmt.executeQuery();

            // Get the properties definition.
            ResultSetMetaData meta = rs.getMetaData();
            int propsSize = meta.getColumnCount();
            SQLDataSet.this.setPropertySize(propsSize);
            for (int i = 0; i < propsSize; i++) {
                SQLDataProperty dp = createSQLProperty();
                dp.setPropertyId(meta.getColumnName(i + 1).toLowerCase());
                dp.setType(meta.getColumnType(i + 1));
                dp.setTableName(meta.getTableName(i + 1));
                dp.setColumnName(meta.getColumnName(i + 1));
                addProperty(dp, i);
            }

            // Get rows and populate the data set values.
            while (rs.next()) {
                Object[] row = new Object[propsSize];
                for (int i = 0; i < propsSize; i++) row[i] = rs.getObject(i + 1);
                SQLDataSet.this.addRowValues(row);
            }

            // Once we got the dataset initialized then calculate the domain for each property.
            for (int i = 0; i < properties.length; i++) {
                SQLDataProperty property = (SQLDataProperty) properties[i];
                property.calculateDomain();
            }
        }
        catch (Exception e) {
            if (lastExecutedStmt != null) {
                log.error("Error in load() SQLDataset. SQL = " + lastExecutedStmt.getSQLSentence(), e);
            }
            throw e;
        }
        finally {
            try {
                if (rs != null) rs.close();
            } catch (Exception e) {
                log.warn("Error closing ResultSet: ", e);
            }
            try {
                if (stmt != null) stmt.close();
            } catch (Exception e) {
                log.warn("Error closing PreparedStatement: ", e);
            }
            if (conn != null) {
                conn.close();
            }
            if (conn != null) {
                trace.end();
            }
        }
    }
View Full Code Here

Examples of org.jboss.dashboard.profiler.CodeBlockTrace

    public void setFlush(Boolean flush) {
        this.flush = flush;
    }

    public int doStartTag() throws JspException {
        CodeBlockTrace trace = new JSPIncludeTrace(page).begin();
        try {
            pageContext.include(page);
        } catch (Throwable t) {
            handleError(t);
        } finally {
            trace.end();
        }
        return SKIP_BODY;
    }
View Full Code Here

Examples of org.jboss.dashboard.profiler.CodeBlockTrace

    public CSVDataProperty createCSVProperty() {
        return new CSVDataProperty();
    }

    public void load() throws Exception {
        CodeBlockTrace trace = null;
        try {
            trace = new CSVReadTrace(csvLoader).begin();
            File f = csvLoader.getCsvProviderFile();
            if (f == null || !f.exists() || !f.canRead()) {
                throw new IOException("Can't load data from file : '" + f + "'");
            }

            // Read the header
            FileReader fileReader = new FileReader(f);
            BufferedReader br = new BufferedReader(fileReader);
            csvReader = new CSVReader(br, csvLoader.getCsvSeparatedBy().charAt(0), csvLoader.getCsvQuoteChar().charAt(0), csvLoader.getCsvEscapeChar().charAt(0));
            List<String[]> lines = csvReader.readAll();
            String[] header = lines.get(0);
            String[] firstRow = lines.get(1);

            // Build the CSV data set properties
            setPropertySize(header.length);
            for (int i = 0; i < firstRow.length; i++) {
                String token = header[i];
                String value = firstRow[i];
                Domain domain = calculateDomain(value);
                CSVDataProperty dp = createCSVProperty();
                dp.setPropertyId(token.toLowerCase());
                dp.setDomain(domain);
                addProperty(dp, i);
            }

            // Load the CSV rows
            for (int lc = 1; lc < lines.size(); lc++) {
                String[] line = lines.get(lc);
                Object[] row = new Object[header.length];
                for (int i = 0; i < line.length; i++) {
                    String valueStr = line[i];
                    CSVDataProperty prop = (CSVDataProperty) getProperties()[i];
                    if (!StringUtils.isBlank(valueStr)){
                        row[i] = parseValue(prop, valueStr);
                    } else {
                        row[i] = null;
                    }
                }
                this.addRowValues(row);
            }

        } catch (Exception e) {
            log.error("Error loading CSV data.", e);
            throw e;
        } finally {
            if (trace != null) {
                trace.end();
            }
        }
    }
View Full Code Here

Examples of org.jboss.dashboard.profiler.CodeBlockTrace

    public DataSet buildXYDataSet() {
        DataProperty domainProperty = getDomainProperty();
        DataProperty rangeProperty = getRangeProperty();
        ScalarFunction scalarFunction = getRangeScalarFunction();
        DataSet sourceDataSet = domainProperty.getDataSet();
        CodeBlockTrace trace = new BuildXYDataSetTrace(domainProperty, rangeProperty, scalarFunction).begin();
        try {
            if (domainProperty == null || domainProperty.getDomain() == null) return null;
            if (rangeProperty == null || scalarFunction == null) return null;

            // Group the original data set by the domain property.
            int pivot = sourceDataSet.getPropertyColumn(domainProperty);
            int range = sourceDataSet.getPropertyColumn(rangeProperty);
            int[] columns = new int[] {pivot, range};
            String[] functionCodes = new String[] {CountFunction.CODE, scalarFunction.getCode()};
            return sourceDataSet.groupBy(domainProperty, columns, functionCodes, intervalsSortCriteria, intervalsSortOrder);
        } finally {
            trace.end();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.