Package nz.co.abrahams.asithappens.storage

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


    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;
                    for ( int interval = 0; interval < fetchedMaximum; interval++ ) {
                        intervalStart = startTime + intervalTime * interval;
                        intervalEnd = startTime + intervalTime * (interval + 1);
                        results = dataSetDAO.retrieve(sessionID, set, intervalStart, intervalEnd);
                        dataSets.getDataSet(set).add(results.aggregate(aggregation, intervalStart, intervalEnd));
                        taskProgress = set * fetchedMaximum + interval;
                        checkCancelled();
                        //logger.debug("Point " + interval + " aggregation of " + results + " : (" + results.aggregate(aggregation, intervalStart, intervalEnd) + ")");
                    }
View Full Code Here


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

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

        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++ ) {
                        out.write("Set " + set + ": " + headings[set] + "\n");
                    }
                    out.write("\n");
                   
                    out.write("Set,Time,Value\n");
                    for ( int set = 0; set < headings.length ; set++ ) {
                        dataSet = dataSetDAO.retrieve(sessionID, set);
                        //out.write("Set " + set + ": " + headings[set] + "\n");
                        for ( int i = 0 ; i < dataSet.size() ; i++ ) {
                            point = dataSet.elementAt(i);
                            out.write(set + "," + point.getTime() + "," + point.getValue() + "\n");
                        }
View Full Code Here

TOP

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

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.