sureshanaparti commented on code in PR #8843:
URL: https://github.com/apache/cloudstack/pull/8843#discussion_r1650113723


##########
engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java:
##########
@@ -18,11 +18,44 @@
  */
 package com.cloud.storage.dao;
 
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
 
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+
 public class SnapshotDetailsDaoImpl extends 
ResourceDetailsDaoBase<SnapshotDetailsVO> implements SnapshotDetailsDao {
+    private static final String GET_SNAPSHOT_DETAILS_ON_ZONE = "SELECT s.* 
FROM snapshot_details s LEFT JOIN snapshots ss ON ss.id=s.snapshot_id WHERE 
ss.data_center_id = ? AND s.name = ?";
+
     @Override
     public void addDetail(long resourceId, String key, String value, boolean 
display) {
         super.addDetail(new SnapshotDetailsVO(resourceId, key, value, 
display));
     }
+
+    public List<SnapshotDetailsVO> findDetailsByZoneAndKey(long dcId, String 
key) {
+        StringBuilder sql = new StringBuilder(GET_SNAPSHOT_DETAILS_ON_ZONE);
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        List<SnapshotDetailsVO> snapshotDetailsOnZone = new 
ArrayList<SnapshotDetailsVO>();
+        try (PreparedStatement pstmt = txn.prepareStatement(sql.toString());) {
+            if (pstmt != null) {
+                pstmt.setLong(1, dcId);
+                pstmt.setString(2, key);
+                try (ResultSet rs = pstmt.executeQuery();) {
+                    while (rs.next()) {
+                        snapshotDetailsOnZone.add(toEntityBean(rs, false));
+                    }
+                } catch (SQLException e) {
+                    throw new 
CloudRuntimeException("searchForZoneWideVlans:Exception:" + e.getMessage(), e);

Review Comment:
   @slavkap update msg here, not checking zone-wide vlans here



##########
engine/schema/src/main/java/com/cloud/storage/dao/SnapshotDetailsDaoImpl.java:
##########
@@ -18,11 +18,44 @@
  */
 package com.cloud.storage.dao;
 
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.cloudstack.resourcedetail.ResourceDetailsDaoBase;
 
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.utils.exception.CloudRuntimeException;
+
 public class SnapshotDetailsDaoImpl extends 
ResourceDetailsDaoBase<SnapshotDetailsVO> implements SnapshotDetailsDao {
+    private static final String GET_SNAPSHOT_DETAILS_ON_ZONE = "SELECT s.* 
FROM snapshot_details s LEFT JOIN snapshots ss ON ss.id=s.snapshot_id WHERE 
ss.data_center_id = ? AND s.name = ?";
+
     @Override
     public void addDetail(long resourceId, String key, String value, boolean 
display) {
         super.addDetail(new SnapshotDetailsVO(resourceId, key, value, 
display));
     }
+
+    public List<SnapshotDetailsVO> findDetailsByZoneAndKey(long dcId, String 
key) {
+        StringBuilder sql = new StringBuilder(GET_SNAPSHOT_DETAILS_ON_ZONE);
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        List<SnapshotDetailsVO> snapshotDetailsOnZone = new 
ArrayList<SnapshotDetailsVO>();
+        try (PreparedStatement pstmt = txn.prepareStatement(sql.toString());) {
+            if (pstmt != null) {
+                pstmt.setLong(1, dcId);
+                pstmt.setString(2, key);
+                try (ResultSet rs = pstmt.executeQuery();) {
+                    while (rs.next()) {
+                        snapshotDetailsOnZone.add(toEntityBean(rs, false));
+                    }
+                } catch (SQLException e) {
+                    throw new 
CloudRuntimeException("searchForZoneWideVlans:Exception:" + e.getMessage(), e);
+                }
+            }
+            return snapshotDetailsOnZone;
+        } catch (SQLException e) {
+            throw new 
CloudRuntimeException("searchForZoneWideVlans:Exception:" + e.getMessage(), e);

Review Comment:
   update msg here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to