deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [5/5] git commit: CIMI: Filter sub-collections properly when using $select (DTACLOUD-431)
Date Tue, 29 Jan 2013 13:40:43 GMT
Updated Branches:
  refs/heads/master 39cf10fb3 -> 024be38f6


CIMI: Filter sub-collections properly when using $select (DTACLOUD-431)


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/0fecb95a
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/0fecb95a
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/0fecb95a

Branch: refs/heads/master
Commit: 0fecb95af0c7ee5259a085342e95e93c28ee973e
Parents: c9b25ed
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Jan 23 16:41:21 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Tue Jan 29 14:38:53 2013 +0100

----------------------------------------------------------------------
 server/lib/cimi/models/base.rb   |   11 ++++++++---
 server/lib/cimi/models/schema.rb |    1 +
 2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/0fecb95a/server/lib/cimi/models/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/base.rb b/server/lib/cimi/models/base.rb
index 5fdb69a..1393ae4 100644
--- a/server/lib/cimi/models/base.rb
+++ b/server/lib/cimi/models/base.rb
@@ -170,8 +170,12 @@ class CIMI::Model::Resource
   # Prepare to serialize
   def prepare
     self.class.schema.collections.map { |coll| coll.name }.each do |n|
-      self[n].href = "#{self.id}/#{n}" unless self[n].href
-      self[n].id = "#{self.id}/#{n}" if !self[n].entries.empty?
+      if !@filter_attrs.empty? and !@filter_attrs.include?(n)
+        @attribute_values[n] = nil
+      else
+        self[n].href = "#{self.id}/#{n}" if !self[n].href
+        self[n].id = "#{self.id}/#{n}" if !self[n].entries.empty?
+      end
     end
   end
 
@@ -180,6 +184,7 @@ class CIMI::Model::Resource
   #
   def initialize(values = {})
     names = self.class.schema.attribute_names
+    @filter_attrs = values[:filter_attr_list] || []
     @attribute_values = names.inject(OrderedHash.new) do |hash, name|
       hash[name] = self.class.schema.convert(name, values[name])
       hash
@@ -285,7 +290,7 @@ class CIMI::Model::Base < CIMI::Model::Resource
       result[attr.to_sym] = self.send(attr) if self.respond_to?(attr)
       result
     end
-    self.class.new(attrs)
+    self.class.new(attrs.merge(:filter_attr_list => attr_list))
   end
 
 end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/0fecb95a/server/lib/cimi/models/schema.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models/schema.rb b/server/lib/cimi/models/schema.rb
index 4acd2dc..24a5a0e 100644
--- a/server/lib/cimi/models/schema.rb
+++ b/server/lib/cimi/models/schema.rb
@@ -241,6 +241,7 @@ class CIMI::Model::Schema
     end
 
     def to_xml(model, xml)
+      return if model[name].nil?
       model[name].prepare
       if model[name].entries.empty?
         xml[xml_name] = { "href" => model[name].href }


Mime
View raw message