Package org.socialmusicdiscovery.server.business.model.config

Examples of org.socialmusicdiscovery.server.business.model.config.ConfigurationParameter


        }
        em.getTransaction().begin();

        Query query = em.createQuery("from ConfigurationParameterEntity where id=:id");
        query.setParameter("id","somebooleanparameter");
        ConfigurationParameter param = (ConfigurationParameter) query.getSingleResult();
        assert(param != null);
        assert(param.getValue().equals("true"));
        assert(param.getType().equals(ConfigurationParameter.Type.BOOLEAN));

        query = em.createQuery("from ConfigurationParameterEntity where id=:id");
        query.setParameter("id","somestringparameter");
        param = (ConfigurationParameter) query.getSingleResult();
        assert(param != null);
        assert(param.getValue().equals("hello"));
        assert(param.getType().equals(ConfigurationParameter.Type.STRING));

        query = em.createQuery("from ConfigurationParameterEntity where id=:id");
        query.setParameter("id","somenumberparameter");
        param = (ConfigurationParameter) query.getSingleResult();
        assert(param != null);
        assert(param.getValue().equals("42"));
        assert(param.getType().equals(ConfigurationParameter.Type.INTEGER));

        em.getTransaction().commit();
    }
View Full Code Here


        }
        em.getTransaction().begin();

        Query query = em.createQuery("from ConfigurationParameterEntity where id=:id");
        query.setParameter("id","somebooleanparameter");
        ConfigurationParameter param = (ConfigurationParameter) query.getSingleResult();
        assert(param != null);
        assert(param.getValue().equals("false"));
        assert(param.getType().equals(ConfigurationParameter.Type.BOOLEAN));

        query = em.createQuery("from ConfigurationParameterEntity where id=:id");
        query.setParameter("id","somestringparameter");
        param = (ConfigurationParameter) query.getSingleResult();
        assert(param != null);
        assert(param.getValue().equals("good bye"));
        assert(param.getType().equals(ConfigurationParameter.Type.STRING));

        em.getTransaction().commit();
    }
View Full Code Here

            for (ConfigurationParameter parameter : defaultPluginConfiguration) {
                ConfigurationParameterEntity entity = new ConfigurationParameterEntity(parameter);
                if(!entity.getId().startsWith(pluginConfigurationPath)) {
                    entity.setId(pluginConfigurationPath+entity.getId());
                }
                ConfigurationParameter defaultValue = defaultValueConfigurationManager.getParameter(pluginConfigurationPath+entity.getId());
                if(defaultValue!=null) {
                    entity.setValue(defaultValue.getValue());
                }else if(System.getProperty(pluginConfigurationPath+entity.getId())!=null) {
                    entity.setValue(System.getProperty(pluginConfigurationPath+entity.getId()));
                }
                entity.setDefaultValue(true);
                defaultConfiguration.add(entity);
            }
            ConfigurationParameter enabledParameter = defaultValueConfigurationManager.getParameter(pluginConfigurationPath+"enabled");
            defaultValueConfigurationManager.setParametersForPath(pluginConfigurationPath, defaultConfiguration);
            if(enabledParameter!=null) {
                enabledParameter.setDefaultValue(true);
                defaultValueConfigurationManager.setParameter(enabledParameter);
            }

            if(defaultValueConfigurationManager.getParameter(pluginConfigurationPath+"enabled")==null && System.getProperty(pluginConfigurationPath+"enabled")!=null) {
                defaultValueConfigurationManager.setParameter(new ConfigurationParameterEntity(pluginConfigurationPath+"enabled", ConfigurationParameter.Type.BOOLEAN, System.getProperty(pluginConfigurationPath+"enabled"), true));
View Full Code Here

            for (ConfigurationParameter parameter : defaultPluginConfiguration) {
                ConfigurationParameterEntity entity = new ConfigurationParameterEntity(parameter);
                if (!entity.getId().startsWith(pluginConfigurationPath)) {
                    entity.setId(pluginConfigurationPath + entity.getId());
                }
                ConfigurationParameter defaultValue = defaultValueConfigurationManager.getParameter(entity.getId());
                if (defaultValue != null) {
                    entity.setValue(defaultValue.getValue());
                } else if (System.getProperty(entity.getId()) != null) {
                    entity.setValue(System.getProperty(entity.getId()));
                }
                entity.setDefaultValue(true);
                defaultConfiguration.add(entity);
View Full Code Here

    @Test
    public void testCRUDConfig() throws Exception {
        MemoryConfigurationManager defaultValueConfigurationManager = InjectHelper.instanceWithName(MemoryConfigurationManager.class, "default-value");
        defaultValueConfigurationManager.setParametersForPath("",new ArrayList<ConfigurationParameter>());

        ConfigurationParameter myBooleanConfig = new ConfigurationParameterEntity();
        myBooleanConfig.setId("somebooleanconfig");
        myBooleanConfig.setType(ConfigurationParameter.Type.BOOLEAN);
        myBooleanConfig.setValue("true");
        ConfigurationParameter  p = Client.create(config).resource(HOSTURL+"/configurations").type(MediaType.APPLICATION_JSON).post(ConfigurationParameter.class,myBooleanConfig);
        assert p!=null;
        assert p.getType().equals(ConfigurationParameter.Type.BOOLEAN);
        assert p.getValue().equals("true");
        p = Client.create(config).resource(HOSTURL+"/configurations/"+p.getId()).accept(MediaType.APPLICATION_JSON).get(ConfigurationParameter.class);
        assert p!=null;
        assert p.getType().equals(ConfigurationParameter.Type.BOOLEAN);
        assert p.getValue().equals("true");

        ConfigurationParameter myNumberConfig = new ConfigurationParameterEntity();
        myNumberConfig.setId("somenumberconfig");
        myNumberConfig.setType(ConfigurationParameter.Type.INTEGER);
        myNumberConfig.setValue("42");
        p = Client.create(config).resource(HOSTURL+"/configurations").type(MediaType.APPLICATION_JSON).post(ConfigurationParameter.class,myNumberConfig);
        assert p!=null;
        assert p.getType().equals(ConfigurationParameter.Type.INTEGER);
        assert p.getValue().equals("42");
        p = Client.create(config).resource(HOSTURL+"/configurations/"+p.getId()).accept(MediaType.APPLICATION_JSON).get(ConfigurationParameter.class);
        assert p!=null;
        assert p.getType().equals(ConfigurationParameter.Type.INTEGER);
        assert p.getValue().equals("42");

        ConfigurationParameter myStringConfig = new ConfigurationParameterEntity();
        myStringConfig.setId("somestringconfig");
        myStringConfig.setType(ConfigurationParameter.Type.STRING);
        myStringConfig.setValue("hello");
        p = Client.create(config).resource(HOSTURL+"/configurations").type(MediaType.APPLICATION_JSON).post(ConfigurationParameter.class,myStringConfig);
        assert p!=null;
        assert p.getType().equals(ConfigurationParameter.Type.STRING);
        assert p.getValue().equals("hello");
        p = Client.create(config).resource(HOSTURL+"/configurations/"+p.getId()).accept(MediaType.APPLICATION_JSON).get(ConfigurationParameter.class);
View Full Code Here

     * @param defaultValue The default value to use if parameter doesn't exist
     * @return The value of the configuration parameter
     */
    @Override
    public String getStringParameter(String id, String defaultValue) {
        ConfigurationParameter parameter = configurationManager.getParameter(configurationPrefix + id);
        return parameter != null && parameter.getValue() != null ? parameter.getValue() : defaultValue;
    }
View Full Code Here

TOP

Related Classes of org.socialmusicdiscovery.server.business.model.config.ConfigurationParameter

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.