Moti Asayag has uploaded a new change for review.

Change subject: engine: Modify custom properties type to map
......................................................................

engine: Modify custom properties type to map

The patch modifies the vnic profile custom properties
type to a map which is more usable and serves it purpose
better than a plan string.

Change-Id: I668a7d821e46e239325b8a021e04746041dbdad5
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
3 files changed, 15 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/16891/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java
index 52e4ceb..b7d92cb 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java
@@ -1,5 +1,7 @@
 package org.ovirt.engine.core.common.businessentities.network;
 
+import java.util.Map;
+
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Pattern;
 import javax.validation.constraints.Size;
@@ -25,7 +27,7 @@
     @NotNull
     private Guid networkId;
     private boolean portMirroring;
-    private String customProperties;
+    private Map<String, String> customProperties;
 
     @Override
     public Guid getId() {
@@ -54,11 +56,11 @@
         this.portMirroring = portMirroring;
     }
 
-    public String getCustomProperties() {
+    public Map<String, String> getCustomProperties() {
         return customProperties;
     }
 
-    public void setCustomProperties(String customProperties) {
+    public void setCustomProperties(Map<String, String> customProperties) {
         this.customProperties = customProperties;
     }
 
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java
index 54b1ad7..39ba2ca 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java
@@ -2,11 +2,13 @@
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.LinkedHashMap;
 import java.util.List;
 
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dao.DefaultGenericDaoDbFacade;
+import org.ovirt.engine.core.utils.SerializationFactory;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 
@@ -65,7 +67,8 @@
                 .addValue("name", profile.getName())
                 .addValue("network_id", profile.getNetworkId())
                 .addValue("port_mirroring", profile.isPortMirroring())
-                .addValue("custom_properties", profile.getCustomProperties());
+                .addValue("custom_properties",
+                        
SerializationFactory.getSerializer().serialize(profile.getCustomProperties()));
     }
 
     @Override
@@ -83,12 +86,14 @@
         public final static VnicProfileRowMapper INSTANCE = new 
VnicProfileRowMapper();
 
         @Override
+        @SuppressWarnings("unchecked")
         public VnicProfile mapRow(ResultSet rs, int rowNum) throws 
SQLException {
             VnicProfile entity = new VnicProfile();
             entity.setId(Guid.createGuidFromString(rs.getString("id")));
             entity.setName(rs.getString("name"));
             
entity.setNetworkId(Guid.createGuidFromString(rs.getString("network_id")));
-            entity.setCustomProperties(rs.getString("custom_properties"));
+            entity.setCustomProperties(SerializationFactory.getDeserializer()
+                    .deserializeOrCreateNew(rs.getString("custom_properties"), 
LinkedHashMap.class));
             entity.setPortMirroring(rs.getBoolean("port_mirroring"));
             return entity;
         }
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 4585efb..b729917 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -865,7 +865,7 @@
             <value>engine_profile_pm</value>
             <value>58d5c1c6-cb15-4832-b2a4-023770607188</value>
             <value>true</value>
-            <value></value>
+            <null />
             <value>2013-07-02 08:38:36</value>
             <value>2013-07-02 08:38:36</value>
         </row>
@@ -874,7 +874,7 @@
             <value>engine2_profile</value>
             <value>58d5c1c6-cb15-4832-b2a4-023770607189</value>
             <value>false</value>
-            <value></value>
+            <value>{ "prop1" : "true", "prop2" : "123456" }</value>
             <value>2013-07-02 08:38:36</value>
             <value>2013-07-02 08:38:36</value>
         </row>
@@ -883,7 +883,7 @@
             <value>engine3_profile</value>
             <value>58d5c1c6-cb15-4832-b2a4-023770607190</value>
             <value>false</value>
-            <value></value>
+            <value>{ "prop1" : "true" }</value>
             <value>2013-07-02 08:38:36</value>
             <value>2013-07-02 08:38:36</value>
         </row>


-- 
To view, visit http://gerrit.ovirt.org/16891
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I668a7d821e46e239325b8a021e04746041dbdad5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Moti Asayag <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to