--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.config;
+
+/**
+ * @since 3.3
+ */
+public class PropertySetValue {
+}
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchComponent;
+import org.sonar.api.PropertyType;
import org.sonar.api.ServerComponent;
import org.sonar.api.utils.DateUtils;
import javax.annotation.Nullable;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
/**
* Project Settings on batch side, Global Settings on server side. This component does not access to database, so
return getStringArrayBySeparator(key, ",");
}
+ public final PropertySetValue getPropertySetValue(String key) {
+ PropertyDefinition property = getDefinitions().get(key);
+ if ((null == property) || (property.getType() != PropertyType.PROPERTY_SET)) {
+ throw new IllegalArgumentException("Property " + key + " is not of type PROPERTY_SET");
+ }
+
+ String propertySetValueName = getString(key);
+
+ // read json for given key
+ // search value for given propertySetValueName
+
+ return null;
+ }
+
/**
* Value is split by carriage returns.
*
# License along with {library}; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
-class PropertySet
- def self.findAll(property_set_name)
- [property_set_name + '1', property_set_name + '2']
+class PropertySet < ActiveRecord::Base
+ attr_accessor :name
+
+ def self.columns
+ @columns ||= [];
+ end
+
+ def self.column(name, sql_type = nil, default = nil, null = true)
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
+ end
+
+ def self.findAll(set_name)
+ ActiveSupport::JSON.decode(values_as_json(set_name)).map { |set| PropertySet.new(set) }
+ end
+
+ def save(validate = true)
+ validate ? valid? : true
+ end
+
+ private
+
+ def self.values_as_json(set_name)
+ json = Property.value('sonar.property_set.' + set_name)
+
+ #json || '[]'
+ json || '[{"name":"set1"},{"name":"set2"}]'
end
end
<select name="<%= input_name(property) -%>" id="input_<%= h property.key -%>">
<option value=""><%= message('default') -%></option>
- <% property_set_values(property).each do |option| %>
+ <% property_set_values(property).map(&:name).each do |option| %>
<option value="<%= h option -%>" <%= 'selected' if value && value==option -%>><%= h option -%></option>
<% end %>
<option value="">New value...</option>