Package nz.co.abrahams.asithappens.collectors

Examples of nz.co.abrahams.asithappens.collectors.DataCollectorDAO


        }
    }

    public int createTemplate(DataSets dataSets) throws DBException, UnknownHostException, DAOCreationException {
        DeviceDAO deviceDAO;
        DataCollectorDAO collectorDAO;
        PreparedStatement statement;
        ResultSet results;
        int sessionID;

        try {
            deviceDAO = DAOFactory.getDeviceDAO();
            deviceDAO.create(dataSets.getDevice());
            deviceDAO.closeConnection();

            statement = connection.prepareStatement(CREATE_TEMPLATE, Statement.RETURN_GENERATED_KEYS);
            statement.setInt(1, dataSets.getDataType().id);
            //statement.setString(2, dataSets.getCollectorName());
            statement.setInt(2, DataCollectorDAOType.getDAOID(dataSets.getCollector().getClass()));
            statement.setInt(3, 0);
            statement.setString(4, dataSets.getDevice().getName());
            statement.setLong(5, dataSets.getPollInterval());
            statement.setString(6, dataSets.getPortString());
            statement.setLong(7, 0);
            statement.setString(8, dataSets.getTitle());
            statement.setLong(9, dataSets.getDirection());
            statement.setInt(10, dataSets.isStoring() ? 1 : 0);
            statement.executeUpdate();

            results = statement.getGeneratedKeys();
            results.next();
            sessionID = results.getInt(1);
            results.close();
            statement.close();

            // TODO - store collector here
            collectorDAO = DAOFactory.getDataCollectorDAO(connection, dataSets.getCollector());
            collectorDAO.create(sessionID, dataSets.getCollector());
            collectorDAO.closeConnection();
            //dataSets.getCollector().store(sessionID);

            logger.debug("Adding new session with ID " + sessionID);
            return sessionID;
        } catch (SQLException e) {
View Full Code Here


    }

    public DataSets retrieveTemplate(int sessionID) throws DBException, UnknownHostException, SNMPException, DAOCreationException {
        PreparedStatement statement;
        ResultSet results;
        DataCollectorDAO collectorDAO;
        DataCollector collector;
        DataSets data;
        //Device device;
        //int dataTypeID;
        //boolean storing;
        //String portString;
        //String collectorType;

        try {
            collectorDAO = DAOFactory.getDataCollectorDAO(connection, sessionID);
            collector = collectorDAO.retrieve(sessionID);

            statement = connection.prepareStatement(RETRIEVE_TEMPLATE);
            statement.setInt(1, sessionID);
            results = statement.executeQuery();
            results.next();
View Full Code Here

TOP

Related Classes of nz.co.abrahams.asithappens.collectors.DataCollectorDAO

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.