cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/master to aef633f
Date Thu, 07 Nov 2013 22:28:38 GMT
Updated Branches:
  refs/heads/master d0123f959 -> aef633f20


Updated VMSnapshotDetails* to match *Details* pattern (e.g. UserVMDetails*)

Signed-off-by: Edison Su <sudison@gmail.com>


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

Branch: refs/heads/master
Commit: aef633f2033703a712afd9e8f523bb9e85829635
Parents: d0123f9
Author: Chris Suich <chris.suich@netapp.com>
Authored: Thu Nov 7 10:23:21 2013 -0500
Committer: Edison Su <sudison@gmail.com>
Committed: Thu Nov 7 14:28:19 2013 -0800

----------------------------------------------------------------------
 .../cloud/vm/snapshot/VMSnapshotDetailsVO.java  | 44 +++++++++-----------
 .../vm/snapshot/dao/VMSnapshotDetailsDao.java   |  7 ++--
 .../snapshot/dao/VMSnapshotDetailsDaoImpl.java  | 31 +++-----------
 .../vm/snapshot/dao/VmSnapshotDaoTest.java      | 11 +++--
 4 files changed, 34 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aef633f2/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java
index 934dd92..ee8765b 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/VMSnapshotDetailsVO.java
@@ -18,27 +18,25 @@
  */
 package com.cloud.vm.snapshot;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
-import javax.persistence.TableGenerator;
+
+import org.apache.cloudstack.api.ResourceDetail;
 
 @Entity
 @Table(name = "vm_snapshot_details")
-public class VMSnapshotDetailsVO implements InternalIdentity {
+public class VMSnapshotDetailsVO implements ResourceDetail {
     @Id
-    @TableGenerator(name = "vm_snapshot_details_seq", table = "sequence", pkColumnName =
"name", valueColumnName = "value", pkColumnValue = "vm_snapshot_details_seq", allocationSize
= 1)
-    @GeneratedValue(strategy = GenerationType.TABLE)
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
     @Column(name = "id")
     private long id;
 
     @Column(name = "vm_snapshot_id")
-    Long vmSnapshotId;
+    private long resourceId;
 
     @Column(name = "name")
     String name;
@@ -50,38 +48,34 @@ public class VMSnapshotDetailsVO implements InternalIdentity {
 
     }
 
-    public VMSnapshotDetailsVO(Long vmSnapshotId, String name, String value) {
-        this.vmSnapshotId = vmSnapshotId;
+    public VMSnapshotDetailsVO(long vmSnapshotId, String name, String value) {
+        this.resourceId = vmSnapshotId;
         this.name = name;
         this.value = value;
     }
 
-    public Long getVmSnapshotId() {
-        return this.vmSnapshotId;
-    }
-
-    public void setVmSnapshotId(Long vmSnapshotId) {
-        this.vmSnapshotId = vmSnapshotId;
-    }
-
+    @Override
     public String getName() {
         return this.name;
     }
 
-    public void setName(String name) {
-        this.name = name;
-    }
-
+    @Override
     public String getValue() {
         return this.value;
     }
 
-    public void setValue(String value) {
-        this.value = value;
+    @Override
+    public long getId() {
+        return id;
     }
 
     @Override
-    public long getId() {
-       return id;
+    public long getResourceId() {
+        return resourceId;
+    }
+
+    @Override
+    public boolean isDisplay() {
+        return false;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aef633f2/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDao.java b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDao.java
index e84178c..ba2c52c 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDao.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDao.java
@@ -18,11 +18,10 @@
  */
 package com.cloud.vm.snapshot.dao;
 
+import org.apache.cloudstack.resourcedetail.ResourceDetailsDao;
+
 import com.cloud.utils.db.GenericDao;
 import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
 
-import java.util.Map;
-
-public interface VMSnapshotDetailsDao extends GenericDao<VMSnapshotDetailsVO, Long>
{
-    Map<String, String> getDetails(Long vmSnapshotId);
+public interface VMSnapshotDetailsDao extends GenericDao<VMSnapshotDetailsVO, Long>,
ResourceDetailsDao<VMSnapshotDetailsVO> {
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aef633f2/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java
index b528b39..bfa912d 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDetailsDaoImpl.java
@@ -18,35 +18,14 @@
  */
 package com.cloud.vm.snapshot.dao;
 
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
+import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
 
-public class VMSnapshotDetailsDaoImpl extends GenericDaoBase<VMSnapshotDetailsVO, Long>
implements VMSnapshotDetailsDao {
-    protected final SearchBuilder<VMSnapshotDetailsVO> searchDetails;
+public class VMSnapshotDetailsDaoImpl extends ResourceDetailsDaoBase<VMSnapshotDetailsVO>
implements VMSnapshotDetailsDao {
 
-    protected VMSnapshotDetailsDaoImpl() {
-        super();
-        searchDetails = createSearchBuilder();
-        searchDetails.and("vmsnapshotId", searchDetails.entity().getVmSnapshotId(), SearchCriteria.Op.EQ);
-        searchDetails.done();
-    }
     @Override
-    public Map<String, String> getDetails(Long vmSnapshotId) {
-        SearchCriteria<VMSnapshotDetailsVO> sc = searchDetails.create();
-        sc.setParameters("vmsnapshotId", vmSnapshotId);
-
-        List<VMSnapshotDetailsVO> details = listBy(sc);
-        Map<String, String> detailsMap = new HashMap<String, String>();
-        for (VMSnapshotDetailsVO detail : details) {
-            detailsMap.put(detail.getName(), detail.getValue());
-        }
-
-        return detailsMap;
+    public void addDetail(long resourceId, String key, String value) {
+        super.addDetail(new VMSnapshotDetailsVO(resourceId, key, value));
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aef633f2/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java
b/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java
index fc52f89..2a2ef9c 100644
--- a/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java
+++ b/engine/storage/integration-test/test/com/cloud/vm/snapshot/dao/VmSnapshotDaoTest.java
@@ -18,16 +18,19 @@
  */
 package com.cloud.vm.snapshot.dao;
 
-import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
+import java.util.Map;
+
+import javax.inject.Inject;
+
 import junit.framework.Assert;
+
 import org.apache.cloudstack.storage.test.CloudStackTestNGBase;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import javax.inject.Inject;
-import java.util.Map;
+import com.cloud.vm.snapshot.VMSnapshotDetailsVO;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = "classpath:/storageContext.xml")
@@ -39,7 +42,7 @@ public class VmSnapshotDaoTest extends CloudStackTestNGBase {
     public void testVmSnapshotDetails() {
         VMSnapshotDetailsVO detailsVO = new VMSnapshotDetailsVO(1L, "test", "foo");
         vmsnapshotDetailsDao.persist(detailsVO);
-        Map<String, String> details = vmsnapshotDetailsDao.getDetails(1L);
+        Map<String, String> details = vmsnapshotDetailsDao.listDetailsKeyPairs(1L);
         Assert.assertTrue(details.containsKey("test"));
     }
 


Mime
View raw message