Package nz.co.abrahams.asithappens.storage

Examples of nz.co.abrahams.asithappens.storage.DataSetsDAO


        this.connection = connection;
    }
   
    public int createGraph(String layoutName, DataGraph graph) throws DBException, UnknownHostException, DAOCreationException {
        LayoutDAO layoutDAO;
        DataSetsDAO dataSetsDAO;
        TimeSeriesOptionsDAO optionsDAO;
        PreparedStatement statement;
        ResultSet results;
        TimeSeriesContext context;
        int graphID;
        int sessionID;
        int graphOptionsID;
       
        try {
            context = graph.getContext();
            if ( context.getData().isCollector() ) {
                // Store graph context as part of a layout
                if ( layoutName != null ) {
                    //sessionID = context.getData().storeTemplate();
                    dataSetsDAO = DAOFactory.getDataSetsDAO();
                    sessionID = dataSetsDAO.createTemplate(context.getData());
                    dataSetsDAO.closeConnection();
                // All stored collector sessions get their graph context stored
                } else
                    sessionID = context.getData().getSessionID();
                    //collectorID = context.getData().getCollector().store();
            } else {
View Full Code Here


        int graphOptionsID;
        TimeSeriesContext context;
        TimeSeriesOptions options;
        Rectangle graphRectangle;
        DataGraph graph;
        DataSetsDAO dataSetsDAO;
        TimeSeriesOptionsDAO optionsDAO;
        TimeSeriesContext.XAxisScaling xAxisScaling;
       
        try {
            statement = connection.prepareStatement(RETRIEVE_SESSION_ID);
            statement.setInt(1, graphID);
            results = statement.executeQuery();
            results.next();
            sessionID = results.getInt("sessionID");
            results.close();
            statement.close();
            // If from layout, create the empty DataSets from a template
            if ( dataSets == null ) {
                dataSetsDAO = DAOFactory.getDataSetsDAO(connection);
                dataSets = dataSetsDAO.retrieveTemplate(sessionID);
                xAxisScaling = TimeSeriesContext.XAxisScaling.ConstantPixelWidth;
            // if from saved session we already have data loaded
            } else {
                xAxisScaling = TimeSeriesContext.XAxisScaling.AbsoluteBoundaries;
            }
View Full Code Here

     */
    public void loadData() throws DBException {
        //long time;
        DataSet results;
        //DatabaseAccess db;
        DataSetsDAO dataSetsDAO;
        DataSetDAO dataSetDAO;
        int sets;
        String[] headings;
        long intervalStart;
        long intervalEnd;
        long intervalTime;
        int numValues;
        //double pointValue;
        int fetchedMaximum;
       
        dataSets.setSessionID(sessionID);
        dataSets.setStartTime(startTime);
        dataSets.setFinishTime(finishTime);
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
            dataSetDAO = DAOFactory.getDataSetDAO();
            dataSets.setDataType(DataType.types[dataSetsDAO.retrieveSessionDataTypeID(sessionID)]);
            dataSets.setDevice(new Device(dataSetsDAO.retrieveSessionDevice(sessionID)));
            dataSets.setPortString(dataSetsDAO.retrieveSessionPort(sessionID));
            dataSets.setPollInterval(dataSetsDAO.retrieveSessionPollInterval(sessionID));
            dataSets.setTitle(dataSetsDAO.retrieveSessionTitle(sessionID));
            dataSets.setDirection(dataSetsDAO.retrieveSessionDirection(sessionID));
            headings = DAOFactory.getDataHeadingsDAO().retrieve(sessionID);
            for ( int set = 0; set < headings.length; set++ ) {
                dataSets.addSet(headings[set]);
            }
            fetchedMaximum = Configuration.getPropertyInt("data.points.fetched.maximum");
           
            logger.debug("Fetching data for " + headings.length + " data sets ("
                    + startTime + " to " + finishTime + ")");
           
            sets = dataSets.getDataSetCount();
            taskLength = sets * fetchedMaximum;
            for ( int set = 0; set < sets; set++ ) {
                taskProgress = set * fetchedMaximum;
                //logger.debug("Current: " + current);
                numValues = dataSetsDAO.retrieveNumberOfPoints(sessionID, set, startTime, finishTime);
                if ( numValues <= fetchedMaximum ) {
                    dataSets.setDataSet(set, dataSetDAO.retrieve(sessionID, set, startTime, finishTime + 1));
                    checkCancelled();
                } else {
                    intervalTime = ( finishTime - startTime ) / fetchedMaximum;
View Full Code Here

    /** Private constructor - class provides static methods only */
    private DAOFactory() {
    }
   
    public static DataSetsDAO getDataSetsDAO() throws DBException {
        return new DataSetsDAO(DBUtil.getConnection());
    }
View Full Code Here

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

        JFileChooser chooser;
        JOptionPane dialog;
        int returnStatus;
        File savedFile;
        FileWriter out;
        DataSetsDAO dataSetsDAO;
        DataSetDAO dataSetDAO;
        int sessionID;
        String[] headings;
        DataSet dataSet;
        DataPoint point;
       
        savedFile = null;
        dialog = new JOptionPane();
       
        sessionID = getSessionID();
        if ( sessionID == -1 )
            return;
       
        if ( ((JTable)(sessionsPane.getViewport().getView())).getSelectedRowCount() > 1 ) {
            dialog.showMessageDialog(this, "Please select a single session for data export", "Multiple sessions selected", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        try {
            //.testConnection();
            dataSetsDAO = DAOFactory.getDataSetsDAO();
            dataSetDAO = DAOFactory.getDataSetDAO();
            chooser = new JFileChooser();
            returnStatus = chooser.showSaveDialog(this);
            if ( returnStatus == JFileChooser.APPROVE_OPTION ) {
                savedFile = chooser.getSelectedFile();
                if ( ! savedFile.exists() || ( savedFile.exists() && dialog.showConfirmDialog(null,
                        "File already exists - are you sure you want to overwrite it?",
                        "Confirm file overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION ) ) {
                    out = new FileWriter(savedFile);
                   
                    out.write("Title: " + dataSetsDAO.retrieveSessionTitle(sessionID) + "\n");
                    out.write("Description: " + DataSets.retrieveDescription(sessionID) + "\n\n");
                   
                    headings = DAOFactory.getDataHeadingsDAO().retrieve(sessionID);
                   
                    for ( int set = 0 ; set < headings.length ; set++ ) {
View Full Code Here

    private void graphButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_graphButtonActionPerformed

        JOptionPane errorDialog;
        DataSetsLoadTask task;
        ProgressBar progressBar;
        DataSetsDAO dataSetsDAO;
        int sessionID;
        TimeSeriesContext.Aggregation aggregation;
        TimeSeriesContext.Interpolation interpolation;
        SimpleDateFormat dateFormat;
        SimpleDateFormat timeFormat;
        long sessionStartTime;
        long sessionFinishTime;
        long fromDate;
        long toDate;
        String graphTitle;
       
        sessionID = getSessionID();
        if ( sessionID == -1 )
            return;
       
        if ( ((JTable)(sessionsPane.getViewport().getView())).getSelectedRowCount() > 1 ) {
            errorDialog = new JOptionPane();
            errorDialog.showMessageDialog(this, "Please select a single session for graph display", "Multiple sessions selected", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
           
            aggregation = TimeSeriesContext.Aggregation.values()[aggregationCombo.getSelectedIndex()];
            interpolation = TimeSeriesContext.Interpolation.values()[interpolationCombo.getSelectedIndex()];
            //dataTypeID = dba.getDataTypeID(sessionID);
           
            dateFormat = new SimpleDateFormat("dd/MM/yyyy H:mm:ss");
            fromDate = dateFormat.parse(fromDateField.getText() + " " + fromTimeField.getText()).getTime();
            toDate = dateFormat.parse(toDateField.getText() + " " + toTimeField.getText()).getTime();
            sessionStartTime = dataSetsDAO.retrieveSessionStartTime(sessionID);
            sessionFinishTime = dataSetsDAO.retrieveSessionFinishTime(sessionID);
            logger.debug("Creating session from " + fromDate + " to " + toDate);
           
            if ( fromDate < sessionStartTime - 1000 ) {
                errorDialog = new JOptionPane();
                errorDialog.showMessageDialog(this, "The \'From\' date/time must be within the session interval", "Can't display graph", JOptionPane.ERROR_MESSAGE);
View Full Code Here

    private void deleteSessionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSessionButtonActionPerformed
        int[] selections;
        int sessionID;
        boolean currentlyCollecting;
        JOptionPane dialog;
        DataSetsDAO dataSetsDAO;
       
        dialog = new JOptionPane();
        selections = ((JTable)(sessionsPane.getViewport().getView())).getSelectedRows();
        if ( selections.length == 0 ) {
            dialog.showMessageDialog(this, "Please select a session", "No session selected", JOptionPane.ERROR_MESSAGE);
            return;
        }
       
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
           
            currentlyCollecting = false;
            for ( int i = 0 ; i < selections.length ; i++ ) {
                if ( dataSetsDAO.retrieveSessionCollectingState(sessions[selections[i]]) == true ) {
                    currentlyCollecting = true;
                }
            }
           
            if ( currentlyCollecting ) {
View Full Code Here

    }
   
    public void run() {
        int selection;
        int sessionID;
        DataSetsDAO dataSetsDAO;
       
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
            while ( true ) {
                try {
View Full Code Here

        }
    }
   
    /** Reads the sessions from the database into the table. */
    public void displaySessions() {
        DataSetsDAO dataSetsDAO;
        String[][] tableData;
       
        try {
            dataSetsDAO = DAOFactory.getDataSetsDAO();
            sessions = dataSetsDAO.retrieveSessionIDs();
            tableData = new String[sessions.length][TABLE_HEADINGS.length];
            isCollecting = new boolean[sessions.length];
            for ( int i = 0 ; i < sessions.length ; i++ ) {
                tableData[i][0] = dataSetsDAO.retrieveSessionTitle(sessions[i]);
                tableData[i][1] = DataSets.retrieveDescription(sessions[i]);
                isCollecting[i] = dataSetsDAO.retrieveSessionCollectingState(sessions[i]);
            }
           
            /*
            sessionsList = new javax.swing.JList(descriptions);
            sessionsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
View Full Code Here

TOP

Related Classes of nz.co.abrahams.asithappens.storage.DataSetsDAO

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.