You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2013/01/02 13:23:53 UTC

[PATCH core 3/7] CIMI: Improved 'store_attributes_for' to be more smart with properties

From: Michal Fojtik <mf...@redhat.com>

* In JSON the field is called 'properties', but in XML the XmlSimple parser
  call it 'property'. This patch will learn the store_attributes_for method
  how to deal with this.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/cimi/helpers/database_helper.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
index 090f6d8..b581c7b 100644
--- a/server/lib/cimi/helpers/database_helper.rb
+++ b/server/lib/cimi/helpers/database_helper.rb
@@ -44,7 +44,11 @@ module Deltacloud
 
         entity.description = extract_attribute_value('description', attrs) if attrs.has_key? 'description'
         entity.name = extract_attribute_value('name', attrs) if attrs.has_key? 'name'
-        entity.ent_properties = extract_attribute_value('properties', attrs).to_json if attrs.has_key? 'properties'
+        if attrs.has_key? 'properties'
+          entity.ent_properties = extract_attribute_value('properties', attrs).to_json
+        elsif attrs.has_key? 'property'
+          entity.ent_properties = extract_attribute_value('property', attrs).to_json
+        end
 
         entity.save! && entity
       end
-- 
1.8.0.2


Re: [PATCH core 3/7] CIMI: Improved 'store_attributes_for' to be more smart with properties

Posted by "marios@redhat.com" <ma...@redhat.com>.
ack

On 02/01/13 14:23, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
> 
> * In JSON the field is called 'properties', but in XML the XmlSimple parser
>   call it 'property'. This patch will learn the store_attributes_for method
>   how to deal with this.
> 
> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
>  server/lib/cimi/helpers/database_helper.rb | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/server/lib/cimi/helpers/database_helper.rb b/server/lib/cimi/helpers/database_helper.rb
> index 090f6d8..b581c7b 100644
> --- a/server/lib/cimi/helpers/database_helper.rb
> +++ b/server/lib/cimi/helpers/database_helper.rb
> @@ -44,7 +44,11 @@ module Deltacloud
>  
>          entity.description = extract_attribute_value('description', attrs) if attrs.has_key? 'description'
>          entity.name = extract_attribute_value('name', attrs) if attrs.has_key? 'name'
> -        entity.ent_properties = extract_attribute_value('properties', attrs).to_json if attrs.has_key? 'properties'
> +        if attrs.has_key? 'properties'
> +          entity.ent_properties = extract_attribute_value('properties', attrs).to_json
> +        elsif attrs.has_key? 'property'
> +          entity.ent_properties = extract_attribute_value('property', attrs).to_json
> +        end
>  
>          entity.save! && entity
>        end
>