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

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


            Collection<ConfigurationParameter> defaultPluginConfiguration = plugin.getDefaultConfiguration();
            String pluginConfigurationPath = PLUGIN_CONFIGURATION_PATH+plugin.getId()+".";

            Set<ConfigurationParameter> defaultConfiguration = new HashSet<ConfigurationParameter>();
            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));
            }

            // Enable plugins by default unless they have specifically requested a specific default state
            if(defaultValueConfigurationManager.getParameter(pluginConfigurationPath+"enabled")==null) {
                defaultValueConfigurationManager.setParameter(new ConfigurationParameterEntity(pluginConfigurationPath+"enabled", ConfigurationParameter.Type.BOOLEAN, "true", true));
            }
            plugin.setConfiguration(new MappedConfigurationContext(pluginConfigurationPath, new MergedConfigurationManager(new PersistentConfigurationManager())));
        }
    }
View Full Code Here


     * @param menuType   Type of menu
     * @param objectType Type of item
     * @param format     The format to use, see {@link org.socialmusicdiscovery.server.support.format.TitleFormat} for more information
     */
    public void addDefaultItemFormat(MenuType menuType, String objectType, String format) {
        defaultValueConfigurationManager.setParameter(new ConfigurationParameterEntity(getClass().getName() + "." + menuType + ".formats."+objectType, ConfigurationParameter.Type.STRING,format));
    }
View Full Code Here

            Collection<ConfigurationParameter> defaultPluginConfiguration = mediaImporter.getDefaultConfiguration();
            String pluginConfigurationPath = "org.socialmusicdiscovery.server.plugins.mediaimport." + mediaImporter.getId() + ".";

            Set<ConfigurationParameter> defaultConfiguration = new HashSet<ConfigurationParameter>();
            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);
            }
            defaultValueConfigurationManager.setParametersForPath(pluginConfigurationPath, defaultConfiguration);

            mediaImporter.setConfiguration(new MappedConfigurationContext(pluginConfigurationPath, new MergedConfigurationManager(new PersistentConfigurationManager())));
View Full Code Here

                List<ConfigurationParameter> parameters = new ArrayList<ConfigurationParameter>();
                for (Map.Entry<Object, Object> entry : defaultProperties.entrySet()) {
                    String property = entry.getKey().toString();
                    String value = entry.getValue().toString();
                    if(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) {
                        parameters.add(new ConfigurationParameterEntity(property, ConfigurationParameter.Type.BOOLEAN, value));
                    }else {
                        try {
                            if(value.contains(".")) {
                                Double.parseDouble(value);
                                parameters.add(new ConfigurationParameterEntity(property, ConfigurationParameter.Type.DOUBLE, value));
                            }else {
                                Integer.parseInt(value);
                                parameters.add(new ConfigurationParameterEntity(property, ConfigurationParameter.Type.INTEGER, value));
                            }
                        }catch (NumberFormatException e) {
                            parameters.add(new ConfigurationParameterEntity(property, ConfigurationParameter.Type.STRING, value));
                        }
                    }
                }
                configurationManager.setParametersForPath("",parameters);
            }
View Full Code Here

    BrowseMenuManager browseMenuManager;

    @Override
    public Collection<ConfigurationParameter> getDefaultConfiguration() {
        return Arrays.asList(
                (ConfigurationParameter) new ConfigurationParameterEntity("location", ConfigurationParameter.Type.STRING, "SE")
        );
    }
View Full Code Here

    }

    @Override
    public Collection<ConfigurationParameter> getDefaultConfiguration() {
        return new ArrayList<ConfigurationParameter>(Arrays.asList(
                (ConfigurationParameter) new ConfigurationParameterEntity("genres", ConfigurationParameter.Type.BOOLEAN, "true"),
                (ConfigurationParameter) new ConfigurationParameterEntity("styles", ConfigurationParameter.Type.BOOLEAN, "true"),
                (ConfigurationParameter) new ConfigurationParameterEntity("moods", ConfigurationParameter.Type.BOOLEAN, "true"),
                (ConfigurationParameter) new ConfigurationParameterEntity("composers", ConfigurationParameter.Type.BOOLEAN, "true"),
                (ConfigurationParameter) new ConfigurationParameterEntity("conductors", ConfigurationParameter.Type.BOOLEAN, "true")
        ));
    }
View Full Code Here

    }

    @Override
    public Collection<ConfigurationParameter> getDefaultConfiguration() {
        Collection<ConfigurationParameter> parameters = super.getDefaultConfiguration();
        parameters.add(new ConfigurationParameterEntity("musicfolders", ConfigurationParameter.Type.STRING, ""));
        parameters.add(new ConfigurationParameterEntity("separatorCharacters", ConfigurationParameter.Type.STRING, ";"));
        return parameters;
    }
View Full Code Here

            preferencesTableView.setTableData(configurations);
            preferencesTableView.getTableViewRowListeners().add(new TableViewRowListener.Adapter() {
                @Override
                public void rowUpdated(TableView tableView, int index) {
                    TableViewItem item = (TableViewItem) tableView.getTableData().get(index);
                    ConfigurationParameterEntity parameter = new ConfigurationParameterEntity(item.getName(), ConfigurationParameter.Type.valueOf(item.getType()), item.getValue());
                    Client.create(config).resource(HOSTURL + "/configurations/" + item.getName()).type(MediaType.APPLICATION_JSON).put(ConfigurationParameter.class, parameter);
                }
            });

            // Setup listeners for close button
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 id The identity of the configuration parameter
     * @return A {@link ConfigurationParameterEntity} instance or null if it doesn't exist
     */
    public ConfigurationParameterEntity getParameter(String id) {
        ConfigurationParameterEntity result = configurationManager.getParameter(id);
        if (result == null) {
            result = defaultValueConfigurationManager.getParameter(id);
        }
        return result;
    }
View Full Code Here

TOP

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

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.