aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF/app/models/property.rb')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/property.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb
index 976fdf7480a..6371b51242d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/property.rb
@@ -21,9 +21,11 @@ class Property < ActiveRecord::Base
validates_presence_of :prop_key
named_scope :with_key, lambda { |value| {:conditions => {:prop_key, value}} }
+ named_scope :with_value, lambda { |value| {:conditions => {:text_value, value}} }
named_scope :with_resource, lambda { |value| {:conditions => {:resource_id => value}} }
named_scope :with_user, lambda { |value| {:conditions => {:user_id => value}} }
- named_scope :on_resource, :conditions => ['resource_id is not ?', nil]
+ named_scope :with_resources, :conditions => 'resource_id is not null'
+ named_scope :with_users, :conditions => 'user_id is not null'
def key
prop_key
@@ -47,6 +49,18 @@ class Property < ActiveRecord::Base
end
end
+ def self.clear_for_resources(key, value=nil)
+ scope=Property.with_resources().with_key(key)
+ if value
+ scope.with_value(value)
+ end
+ scope.delete_all
+ end
+
+ def self.clear_for_users(key)
+ Property.with_users().with_key(key).delete_all
+ end
+
def self.by_key(key, resource_id=nil, user_id=nil)
all(key, resource_id, user_id).first
end