deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [6/8] git commit: Fixed bugs in storing entity data to database
Date Mon, 21 Jan 2013 09:52:12 GMT
Fixed bugs in storing entity data to database


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

Branch: refs/heads/master
Commit: 656a464d975ef3bb6103c80c42ea2e441ccc2d7c
Parents: 3c2e811
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Wed Jan 16 12:48:12 2013 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Jan 21 10:51:53 2013 +0100

----------------------------------------------------------------------
 server/lib/cimi/helpers/database_helper.rb |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/656a464d/server/lib/cimi/helpers/database_helper.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
index d432f69..e6f73fe 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -54,7 +54,11 @@ module Deltacloud
         return if model.id.nil?
 
         unless entity = get_entity(model)
-          entity = Deltacloud::Database::Entity.new(:provider_id => current_db.id)
+          entity = Deltacloud::Database::Entity.new(
+            :provider_id => current_db.id,
+            :be_id => model.id,
+            :be_kind => model.to_entity
+          )
         end
 
         entity.description = extract_attribute_value('description', attrs) if attrs.has_key?
'description'
@@ -76,7 +80,13 @@ module Deltacloud
       #
       def extract_attribute_value(name, attrs={})
         return unless attrs[name]
-        attrs[name].is_a?(Array) ? attrs[name].first : attrs[name]
+        if name == 'property'
+          attrs[name].is_a?(Array) ?
+            attrs[name].inject({}) { |r, v| r[v['key']] = v['content']; r} :
+            attrs[name]
+        else
+          attrs[name].is_a?(Array) ? attrs[name].first : attrs[name]
+        end
       end
 
     end


Mime
View raw message