Package fr.soleil.salsa.persistence.model

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


    @Override
    public IConfig<?> getConfigById(Integer id) throws ScanNotFoundException {
        IConfig<?> result = null;

        ConfigDAOJdbcImpl dao = new ConfigDAOJdbcImpl();
        Configuration c = dao.getConfigById(id);

        try {
            if (c != null) {
                result = (IConfig<?>) ConfigAsXmlHelper.fromXml(c.getData());
                // result.setName(c.getName());

                result.setLoaded(true);
                result.setId(id);
                result.setTimestamp(c.getTimestamp());
                result.setDirectory(c.getDirectory());

                if (c.getType().equals("Config1DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_1D);
                }
                else if (c.getType().equals("Config2DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_2D);
                }
                else if (c.getType().equals("ConfigHCS")) {
                    result.setType(IConfig.ScanType.SCAN_HCS);
                }
                else if (c.getType().equals("ConfigK")) {
                    result.setType(IConfig.ScanType.SCAN_K);
                }
                else if (c.getType().equals("ConfigEnergy")) {
                    result.setType(IConfig.ScanType.SCAN_ENERGY);
                }

                if (result instanceof IConfig<?>) {
                    IConfig<?> sc = (IConfig<?>) result;
                    sc.setChartProperties(c.getChartProperties());
                    sc.setPlotPropertiesMap(c.getPlotPropertiesMap());
                }
                c.clean();
            }
            if (result == null) {
                StringBuilder builder = new StringBuilder(
                        "Failed to find configuration matching id = ");
                builder.append(id);
View Full Code Here


    @Override
    public IConfig<?> getConfigById(Integer id) throws ScanNotFoundException {
        IConfig<?> result = null;

        ConfigDAOJdbcImpl dao = new ConfigDAOJdbcImpl();
        Configuration c = dao.getConfigById(id);

        try {
            if (c != null) {
                result = (IConfig<?>) ConfigAsXmlHelper.fromXml(c.getData());
                // result.setName(c.getName());

                result.setLoaded(true);
                result.setId(id);
                result.setTimestamp(c.getTimestamp());
                result.setDirectory(c.getDirectory());

                if (c.getType().equals("Config1DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_1D);
                } else if (c.getType().equals("Config2DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_2D);
                } else if (c.getType().equals("ConfigHCS")) {
                    result.setType(IConfig.ScanType.SCAN_HCS);
                } else if (c.getType().equals("ConfigK")) {
                    result.setType(IConfig.ScanType.SCAN_K);
                } else if (c.getType().equals("ConfigEnergy")) {
                    result.setType(IConfig.ScanType.SCAN_ENERGY);
                }

                c.clean();
            }
            if (result == null) {
                StringBuilder builder = new StringBuilder("Failed to find configuration matching id = ");
                builder.append(id);
                throw new ScanNotFoundException(builder.toString());
View Full Code Here

        }
        catch (ConversionException e) {
            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

        } 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());

        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

        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

        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

    @Override
    public IConfig<?> getConfigById(Integer id) throws ScanNotFoundException {
        IConfig<?> result = null;

        ConfigDAOJdbcImpl dao = new ConfigDAOJdbcImpl();
        Configuration c = dao.getConfigById(id);

        try {
            if (c != null) {
                result = (IConfig<?>) ConfigAsXmlHelper.fromXml(c.getData());
                // result.setName(c.getName());

                result.setLoaded(true);
                result.setId(id);
                result.setTimestamp(c.getTimestamp());
                result.setDirectory(c.getDirectory());

                if (c.getType().equals("Config1DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_1D);
                }
                else if (c.getType().equals("Config2DImpl")) {
                    result.setType(IConfig.ScanType.SCAN_2D);
                }
                else if (c.getType().equals("ConfigHCS")) {
                    result.setType(IConfig.ScanType.SCAN_HCS);
                }
                else if (c.getType().equals("ConfigK")) {
                    result.setType(IConfig.ScanType.SCAN_K);
                }
                else if (c.getType().equals("ConfigEnergy")) {
                    result.setType(IConfig.ScanType.SCAN_ENERGY);
                }

                if (result instanceof ISpectrumConfig<?>) {
                    ISpectrumConfig<?> sc = (ISpectrumConfig<?>) result;
                    sc.setChartProperties(c.getChartProperties());
                    sc.setPlotPropertiesMap(c.getPlotPropertiesMap());
                }
                c.clean();
            }
            if (result == null) {
                StringBuilder builder = new StringBuilder(
                        "Failed to find configuration matching id = ");
                builder.append(id);
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.