Package fr.soleil.salsa.persistence.model

Examples of fr.soleil.salsa.persistence.model.Configuration


        catch (ConversionException e) {
            e.printStackTrace();
            throw new PersistenceException(e.getMessage(), e);
        }

        Configuration c = new Configuration();

        c.setId(config.getId());
        c.setName(config.getName());
        c.setType(config.getClass().getSimpleName());
        c.setDirectory(config.getDirectory());
        try {
            c.setData(ConfigAsXmlHelper.xmlToString(d));
        }
        catch (ConversionException e) {
            e.printStackTrace();
        }
        // System.out.println("Configuration data =" + c.getData());
        // Parent directory need to be defined !!
        c.setDirectoryId(config.getDirectory().getId());
        c.setTimestamp(config.getTimestamp());
        if (config instanceof IConfig<?>) {
            IConfig<?> sc = (IConfig<?>) config;
            c.setChartProperties(sc.getChartProperties());
            c.setPlotPropertiesMap(sc.getPlotPropertiesMap());
        }

        dao.saveConfig(c, config.isForcedSaving());

        if (c.getId() != null) {
            result = getConfigById(c.getId());
            // The timestamp is not defined by the getConfigById,
            // so we need to set his value explicitly with
            // the one provided by the save operation.
            if (result.getDirectory() != null && c.getDirectory() != null) {
                result.getDirectory().setTimestamp(c.getDirectory().getTimestamp());
            }
            result.setModified(false);
        }
        c.clean();
        // System.out.println("Actuator= " + result.getDimensionX().getActuatorsList().size());
        return result;
    }
View Full Code Here


            SQLException {

        if (configuration == null || configuration.getId() == null)
            return;

        Configuration configResultat = null;

        // Load the config
        configResultat = getConfigById(configuration.getId());

        // Case when the entity is NULL
        if (configResultat == null
                || !configResultat.getTimestamp().equals(configuration.getTimestamp())) {
            throw new ScanConfigOutOfSyncException();
        }

        // delete the config
        deleteConfigNoCommitAux(configuration);
View Full Code Here

            CommonsJDBC.catchException(ex);
        }
    }

    public Configuration getConfigById(Integer id) {
        Configuration result = null;
        try {
            startOperation();
            result = getConfigByIdAux(id);
        }
        catch (SQLException e) {
View Full Code Here

     * @param configId
     * @return Configuration
     */
    private Configuration getConfigByIdAux(Integer configId) throws SQLException {

        Configuration configuration = null;
        String query = "SELECT configid, name, type, data, directoryid, timestamp FROM config WHERE configid="
                + configId;

        ResultSet rs = stmt.executeQuery(query);

        while (rs.next()) {

            configuration = new Configuration();

            configuration.setId(rs.getInt("configid"));
            configuration.setName(rs.getString("name"));
            configuration.setType(rs.getString("type"));
            configuration.setData(rs.getString("data"));
            configuration.setDirectoryId(rs.getInt("directoryid"));
            configuration.setTimestamp(rs.getTimestamp("timestamp"));

            int parentId = rs.getInt("directoryid");

            if (!rs.wasNull()) {
                DirectoryImpl parent = new DirectoryImpl();
                parent.setId(parentId);
                configuration.setDirectoryId(parentId);
                configuration.setDirectory(parent);
                // configuration.setDirectory(getDirectoryById(dir));
            }
        }
        rs.close();
        stmt.clearBatch();
        configuration.setChartProperties(getChartPropertiesByIdAux(configId));
        configuration.setPlotPropertiesMap(getPlotPropertiesByIdAux(configId));

        return configuration;
    }
View Full Code Here

        try {
            startOperation();
            ResultSet rs = stmt.executeQuery(query);

            Configuration config = null;
            while (rs.next()) {

                config = new Configuration();

                config.setId(rs.getInt("configid"));
                config.setName(rs.getString("name"));
                config.setType(rs.getString("type"));
                config.setData(rs.getString("data"));
                config.setDirectoryId(rs.getInt("directoryid"));
                config.setTimestamp(rs.getTimestamp("timestamp"));

                configList.add(config);

            }
            rs.close();
View Full Code Here

        ScanConfigOutOfSyncException exception = null;
        if (config == null) {
            exception = new ScanConfigOutOfSyncException("Can't save a null configuration");
        }
        else {
            Configuration configuration = getConfigById(config.getId());
            boolean newConfig = (configuration == null);
            // Checking if the configuration is out of synchronization
            if ((!newConfig) && (!config.getTimestamp().equals(configuration.getTimestamp()))) {
                exception = new ScanConfigOutOfSyncException();
            }
            else {
                // Checking if the configuration directory has been deleted
                IDirectory directory = getDirectoryById(config.getDirectoryId(), false);
View Full Code Here

        if (configuration == null || configuration.getId() == null) {
            return;
        }

        Configuration configResultat = null;

        // Load the config
        configResultat = getConfigById(configuration.getId());

        // Case when the entity is NULL
        if (configResultat == null
                || !configResultat.getTimestamp().equals(configuration.getTimestamp())) {
            throw new ScanConfigOutOfSyncException();
        }

        // delete the config
        deleteConfigNoCommitAux(configuration);
View Full Code Here

            CommonsJDBC.catchException(ex);
        }
    }

    public Configuration getConfigById(Integer id) {
        Configuration result = null;
        try {
            startOperation();
            result = getConfigByIdAux(id);
        }
        catch (SQLException e) {
View Full Code Here

     * @param configId
     * @return Configuration
     */
    private Configuration getConfigByIdAux(Integer configId) throws SQLException {

        Configuration configuration = null;
        String query = "SELECT configid, name, type, data, directoryid, timestamp FROM config WHERE configid="
                + configId;

        if (stmt != null) {
            ResultSet rs = stmt.executeQuery(query);

            while (rs.next()) {

                configuration = new Configuration();

                configuration.setId(rs.getInt("configid"));
                configuration.setName(rs.getString("name"));
                configuration.setType(rs.getString("type"));
                configuration.setData(rs.getString("data"));
                int directoryid = rs.getInt("directoryid");
                configuration.setDirectoryId(directoryid);
                configuration.setTimestamp(rs.getTimestamp("timestamp"));
            }
            rs.close();
            stmt.clearBatch();
            if (configuration != null) {
                configuration.setChartProperties(getChartPropertiesByIdAux(configId));
                configuration.setPlotPropertiesMap(getPlotPropertiesByIdAux(configId));

                int directoryid = configuration.getDirectoryId();
                // System.out.println("directoryid=" + directoryid);
                IDirectory directory = getDirectoryById(directoryid, true);
                if (directory != null) {
                    // IDirectory parent = directory.getDirectory();
                    configuration.setDirectory(directory);
                }
            }

        }
        return configuration;
View Full Code Here

        try {
            startOperation();
            if (stmt != null) {
                ResultSet rs = stmt.executeQuery(query);

                Configuration config = null;
                while (rs.next()) {
                    config = new Configuration();

                    config.setId(rs.getInt("configid"));
                    config.setName(rs.getString("name"));
                    config.setType(rs.getString("type"));
                    config.setData(rs.getString("data"));
                    config.setDirectoryId(rs.getInt("directoryid"));
                    config.setTimestamp(rs.getTimestamp("timestamp"));
                    configList.add(config);
                    // System.out.println("Config name=" + config.getName());

                }
                rs.close();
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.persistence.model.Configuration

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.