From 34a14aa9e0884a23a1a4a41d66bd1a305ed282a2 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Wed, 19 Jun 2019 22:07:06 +0530 Subject: [PATCH] Improve review management DAO --- .../mgt/common/response/Review.java | 36 ++++++++----------- .../core/dao/impl/review/ReviewDAOImpl.java | 4 +-- .../mgt/core/impl/ReviewManagerImpl.java | 4 +-- 3 files changed, 18 insertions(+), 26 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Review.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Review.java index e77bbacc06..1c0285fbb4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Review.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Review.java @@ -32,12 +32,6 @@ public class Review { @ApiModelProperty(name = "content", value = "Review message.") private String content; - @ApiModelProperty(name = "rootParentId", value = "Root Parent id of the review") - private int rootParentId; - - @ApiModelProperty(name = "immediateParentId", value = "Immediate Parent id of the review") - private int immediateParentId; - @ApiModelProperty(name = "username", value = "Username odf the Review creator") private String username; @@ -50,6 +44,12 @@ public class Review { @ApiModelProperty(name = "rating", value = "Rating value of the application release") private int rating; + @ApiModelProperty(name = "releaseUuid", value = "UUID of the review associated application") + private String releaseUuid; + + @ApiModelProperty(name = "releaseVersion", value = "Version of the review associated application") + private String releaseVersion; + @ApiModelProperty(name = "replies", value = "Replying reviews") private List replies; @@ -69,22 +69,6 @@ public class Review { this.content = content; } - public int getRootParentId() { - return rootParentId; - } - - public void setRootParentId(int rootParentId) { - this.rootParentId = rootParentId; - } - - public int getImmediateParentId() { - return immediateParentId; - } - - public void setImmediateParentId(int immediateParentId) { - this.immediateParentId = immediateParentId; - } - public String getUsername() { return username; } @@ -120,4 +104,12 @@ public class Review { public List getReplies() { return replies; } public void setReplies(List replies) { this.replies = replies; } + + public String getReleaseUuid() { return releaseUuid; } + + public void setReleaseUuid(String releaseUuid) { this.releaseUuid = releaseUuid; } + + public String getReleaseVersion() { return releaseVersion; } + + public void setReleaseVersion(String releaseVersion) { this.releaseVersion = releaseVersion; } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java index b57486690a..73659390cc 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/review/ReviewDAOImpl.java @@ -110,7 +110,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { try { conn = this.getDBConnection(); StringJoiner joiner = new StringJoiner(",", - "SELECT rv.ID FROM AP_APP_REVIEW rv " + "WHERE rv.AP_APP_RELEASE_ID IN (", + "SELECT rv.ID FROM AP_APP_REVIEW rv WHERE rv.AP_APP_RELEASE_ID IN (", ") AND rv.USERNAME = ? AND rv.TENANT_ID = ?"); appReleaseIds.stream().map(ignored -> "?").forEach(joiner::add); String query = joiner.toString(); @@ -118,7 +118,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { for (Integer deviceId : appReleaseIds) { ps.setObject(index++, deviceId); } - ps.setInt(index++, tenantId); + ps.setString(index++, username); ps.setInt(index, tenantId); try (ResultSet rs = ps.executeQuery()) { return rs.next(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java index 6b605ef9de..01f384d288 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ReviewManagerImpl.java @@ -238,8 +238,8 @@ public class ReviewManagerImpl implements ReviewManager { Review review = new Review(); review.setId(reviewDTO.getId()); review.setContent(reviewDTO.getContent()); - review.setRootParentId(reviewDTO.getRootParentId()); - review.setImmediateParentId(reviewDTO.getImmediateParentId()); + review.setReleaseUuid(reviewDTO.getReleaseUuid()); + review.setReleaseVersion(reviewDTO.getReleaseVersion()); review.setCreatedAt(reviewDTO.getCreatedAt()); review.setModifiedAt(reviewDTO.getModifiedAt()); review.setRating(reviewDTO.getRating());