You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by ma...@apache.org on 2012/01/03 17:27:51 UTC

svn commit: r1226851 - /deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb

Author: marios
Date: Tue Jan  3 16:27:50 2012
New Revision: 1226851

URL: http://svn.apache.org/viewvc?rev=1226851&view=rev
Log:
Fixes to logic in CIMI entity_metadata from features - collects all feature params individually

Modified:
    deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb

Modified: deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb?rev=1226851&r1=1226850&r2=1226851&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb (original)
+++ deltacloud/trunk/server/lib/cimi/model/entity_metadata.rb Tue Jan  3 16:27:50 2012
@@ -53,7 +53,7 @@ text :type_uri
   def self.metadata_from_deltacloud_features(cimi_entity, dcloud_entity, context)
       deltacloud_features = context.driver.features(dcloud_entity)
       metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
-      from_feature(cimi_entity, context, metadata_attributes)
+      from_feature(cimi_entity, context, metadata_attributes.flatten!)
   end
 
   def includes_attribute?(attribute)
@@ -63,11 +63,16 @@ text :type_uri
   private
 
   def self.attributes_from_feature(feature)
-    { :name=>(feature.name == :user_name ? :name : feature.name),
-      :type=> "xs:string",
-      :required=>(feature.operations.first.params[feature.name].type == :optional ? "false" : "true"),
-      :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description): feature.constraints)
-    }
+    attributes = []
+    feature.operations.first.params.each_key do |param|
+      attributes << {
+        :name=>(feature.name == :user_name ? :name : param),
+        :type=> "xs:string",
+        :required=>(feature.operations.first.params[param].type == :optional ? "false" : "true"),
+        :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description): feature.constraints)
+                    }
+    end
+    attributes
   end
 
   def self.from_feature(cimi_entity, context, metadata_attributes)