Package nz.co.abrahams.asithappens.uiutil

Examples of nz.co.abrahams.asithappens.uiutil.SetDisplayDAO


    public TimeSeriesOptionsDAO(Connection connection) {
        this.connection = connection;
    }
   
    public int createGraphOptions(TimeSeriesOptions options) throws DBException {
        SetDisplayDAO displayDAO;
        PreparedStatement statement;
        ResultSet results;
        int graphOptionsID;
        int setDisplayID;
       
        try {
            statement = connection.prepareStatement(CREATE_OPTIONS, Statement.RETURN_GENERATED_KEYS);
            statement.setString(1, options.getAggregation().toString());
            statement.setString(2, options.getInterpolation().toString());
            statement.setInt(3, options.getUseFixedGraphTop() ? 1 : 0);
            statement.setDouble(4, options.getFixedGraphTop());
            statement.setString(5, Character.toString(options.getFixedGraphTopUnits()));
            statement.setInt(6, options.getXAxisAbsoluteTimes() ? 1 : 0);
            statement.setInt(7, options.getYAxisFormattedUnits() ? 1 : 0);
            statement.setInt(8, options.getBottomLeftLegend() ? 1 : 0);
            statement.setInt(9, options.getHorizontalGridLines() ? 1 : 0);
            statement.setInt(10, options.getHorizontalMinorLines() ? 1 : 0);
            statement.setInt(11, options.getVerticalGridLines() ? 1 : 0);
            statement.setInt(12, options.getVerticalMinorLines() ? 1 : 0);
            statement.setInt(13, options.getLinesInFront() ? 1 : 0);
            statement.setInt(14, options.getStickyWindow() ? 1 : 0);
            statement.setInt(15, options.getShowLabels() ? 1 : 0);
            statement.setInt(16, options.getShowTrim() ? 1 : 0);
            statement.setString(17, options.getSetsPositioning().toString());
            statement.executeUpdate();
            results = statement.getGeneratedKeys();
            results.next();
            graphOptionsID = results.getInt(1);
            results.close();
            statement.close();
            logger.debug("Adding new graph options with ID " + graphOptionsID);
           
            displayDAO = DAOFactory.getSetDisplayDAO();
            for ( int set = 0 ; set < options.getSetDisplays().size() ; set++ ) {
                //setDisplayID = options.getSetDisplay(set).store();
                setDisplayID = displayDAO.create(options.getSetDisplay(set));
                statement = connection.prepareStatement(CREATE_OPTIONS_SETDISPLAYS);
                statement.setInt(1, graphOptionsID);
                statement.setInt(2, set);
                statement.setInt(3, setDisplayID);
                statement.executeUpdate();
                statement.close();
            }
            displayDAO.closeConnection();
            return graphOptionsID;
        } catch (SQLException e) {
            logger.error("Problem creating graph options in database");
            throw new DBException("Problem creating graph options in database", e);
        }
View Full Code Here


            throw new DBException("Problem creating graph options in database", e);
        }
    }
   
    public void updateGraphOptions(int graphOptionsID, TimeSeriesOptions options) throws DBException {
        SetDisplayDAO displayDAO;
        PreparedStatement statement;
        ResultSet results;
        int graphID;
        int sessionID;
        int setDisplayID;
       
        try {
            statement = connection.prepareStatement(UPDATE_OPTIONS);
            statement.setString(1, options.getAggregation().toString());
            statement.setString(2, options.getInterpolation().toString());
            statement.setInt(3, options.getUseFixedGraphTop() ? 1 : 0);
            statement.setDouble(4, options.getFixedGraphTop());
            statement.setString(5, Character.toString(options.getFixedGraphTopUnits()));
            statement.setInt(6, options.getXAxisAbsoluteTimes() ? 1 : 0);
            statement.setInt(7, options.getYAxisFormattedUnits() ? 1 : 0);
            statement.setInt(8, options.getBottomLeftLegend() ? 1 : 0);
            statement.setInt(9, options.getHorizontalGridLines() ? 1 : 0);
            statement.setInt(10, options.getHorizontalMinorLines() ? 1 : 0);
            statement.setInt(11, options.getVerticalGridLines() ? 1 : 0);
            statement.setInt(12, options.getVerticalMinorLines() ? 1 : 0);
            statement.setInt(13, options.getLinesInFront() ? 1 : 0);
            statement.setInt(14, options.getStickyWindow() ? 1 : 0);
            statement.setInt(15, options.getShowLabels() ? 1 : 0);
            statement.setInt(16, options.getShowTrim() ? 1 : 0);
            statement.setString(17, options.getSetsPositioning().toString());
            statement.setInt(18, graphOptionsID);
            statement.executeUpdate();
            statement.close();
            logger.debug("Updating graph options with ID " + graphOptionsID);
           
            displayDAO = DAOFactory.getSetDisplayDAO();
            for ( int set = 0 ; set < options.getSetDisplays().size() ; set++ ) {
                statement = connection.prepareStatement(RETRIEVE_SETDISPLAYID);
                statement.setInt(1, graphOptionsID);
                statement.setInt(2, set);
                results = statement.executeQuery();
                results.next();
                logger.info("SetDisplayID: " + results.getInt(1));
                displayDAO.update(results.getInt(1), options.getSetDisplay(set));
                results.close();
                statement.close();
            }
            displayDAO.closeConnection();
           
        } catch (SQLException e) {
            logger.error("Problem Updating graph options in database");
            throw new DBException("Problem Updating graph options in database", e);
        }
View Full Code Here

    public TimeSeriesOptions retrieveGraphOptions(int graphOptionsID) throws DBException {
        PreparedStatement statement;
        ResultSet results;
        TimeSeriesOptions options;
        Vector<SetDisplay> setDisplays;
        SetDisplayDAO setDisplayDAO;
       
        try {
            statement = connection.prepareStatement(RETRIEVE_OPTIONS);
            statement.setInt(1, graphOptionsID);
            results = statement.executeQuery();
            results.next();
            options = new TimeSeriesOptions();
            options.setAggregation(TimeSeriesContext.Aggregation.valueOf(results.getString("aggregation")));
            options.setInterpolation(TimeSeriesContext.Interpolation.valueOf(results.getString("interpolation")));
            options.setSetsPositioning(SetDisplay.Positioning.valueOf(results.getString("setsPositioning")));
            options.setFixedGraphTop(results.getDouble("fixedGraphTop"));
            // unimplemented, but add if needed:
            options.setYAxisFormattedUnits(results.getInt("yAxisFormatUnits") == 1);
            options.setBottomLeftLegend(results.getInt("bottomLeftLegend") == 1);
            try {
                options.setFixedGraphTopUnits(results.getString("fixedGraphTopUnits").charAt(0));
            } catch (StringIndexOutOfBoundsException e) {
                options.setFixedGraphTopUnits(' ');
            }
            options.setXAxisAbsoluteTimes(results.getInt("xAxisAbsoluteTimes") == 1);
            options.setHorizontalGridLines(results.getInt("horizontalGridLines") == 1);
            options.setHorizontalMinorLines(results.getInt("horizontalMinorLines") == 1);
            options.setVerticalGridLines(results.getInt("verticalGridLines") == 1);
            options.setVerticalMinorLines(results.getInt("verticalMinorLines") == 1);
            options.setLinesInFront(results.getInt("linesInFront") == 1);
            options.setStickyWindow(results.getInt("stickyWindow") == 1);
            options.setShowLabels(results.getInt("showLabels") == 1);
            options.setShowTrim(results.getInt("showTrim") == 1);
            results.close();
            statement.close();
           
            setDisplayDAO = DAOFactory.getSetDisplayDAO(connection);
            setDisplays = setDisplayDAO.retrieve(graphOptionsID);
            options.setSetDisplays(setDisplays);
            logger.debug(options.toString());
            return options;
        } catch (SQLException e) {
            e.printStackTrace();
View Full Code Here

    public static TimeSeriesOptionsDAO getGraphOptionsDAO(Connection connection) throws DBException {
        return new TimeSeriesOptionsDAO(connection);
    }
   
    public static SetDisplayDAO getSetDisplayDAO() throws DBException {
        return new SetDisplayDAO(DBUtil.getConnection());
    }
View Full Code Here

    public static SetDisplayDAO getSetDisplayDAO() throws DBException {
        return new SetDisplayDAO(DBUtil.getConnection());
    }
   
    public static SetDisplayDAO getSetDisplayDAO(Connection connection) throws DBException {
        return new SetDisplayDAO(connection);
    }
View Full Code Here

TOP

Related Classes of nz.co.abrahams.asithappens.uiutil.SetDisplayDAO

Copyright © 2018 www.massapicom. 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.