aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/models
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-09-24 19:14:20 +0200
committerDavid Gageot <david@gageot.net>2012-09-24 19:24:13 +0200
commit082a1b5cf450f5f0837d0d51efe3a4f90c24181b (patch)
tree6040617bb6152d5b339922e26444ba21cd1796ab /sonar-server/src/main/webapp/WEB-INF/app/models
parentdffab878ddf772d36f56b94ee1a739bc3fc1a984 (diff)
downloadsonarqube-082a1b5cf450f5f0837d0d51efe3a4f90c24181b.tar.gz
sonarqube-082a1b5cf450f5f0837d0d51efe3a4f90c24181b.zip
SONAR-3529 API: ability to define property sets.
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/models')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb29
1 files changed, 26 insertions, 3 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb
index 61007210470..b7e20fe1a1e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property_set.rb
@@ -17,8 +17,31 @@
# 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