From 26a049473c6f067945be32d5c5dd1c0dab32a1ac Mon Sep 17 00:00:00 2001 From: Sasini_Sandamali Date: Tue, 12 Sep 2023 16:02:31 +0530 Subject: [PATCH] Modify View Activities endpoint by including operation id --- .../api/ActivityInfoProviderService.java | 5 +++++ .../impl/ActivityProviderServiceImpl.java | 4 ++++ .../mgt/common/ActivityPaginationRequest.java | 9 +++++++++ .../mgt/common/operation/mgt/Activity.java | 16 ++++++++++++++++ .../mgt/dao/impl/GenericOperationDAOImpl.java | 18 ++++++++++++++++++ .../mgt/dao/util/OperationDAOUtil.java | 1 + 6 files changed, 53 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java index 23076328e4..240f6bfb01 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/ActivityInfoProviderService.java @@ -466,6 +466,11 @@ public interface ActivityInfoProviderService { value = "Operation Code to filter" ) @QueryParam("operationCode") String operationCode, + @ApiParam( + name = "operationId", + value = "Operation Id to filter" + ) + @QueryParam("operationId") int operationId, @ApiParam( name = "deviceType", value = "Device Type to filter" diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java index d9fec4b91b..0474a81a79 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ActivityProviderServiceImpl.java @@ -253,6 +253,7 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService @QueryParam("since") String since, @QueryParam("initiatedBy") String initiatedBy, @QueryParam("operationCode") String operationCode, + @QueryParam("operationId") int operationId, @QueryParam("deviceType") String deviceType, @QueryParam("deviceId") List deviceIds, @QueryParam("type") String type, @@ -321,6 +322,9 @@ public class ActivityProviderServiceImpl implements ActivityInfoProviderService if (operationCode != null && !operationCode.isEmpty()) { activityPaginationRequest.setOperationCode(operationCode); } + if (operationId > 0) { + activityPaginationRequest.setOperationId(operationId); + } if (deviceType != null && !deviceType.isEmpty()) { activityPaginationRequest.setDeviceType(deviceType); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java index b535ab4bd6..058b82dd2f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/ActivityPaginationRequest.java @@ -32,6 +32,7 @@ public class ActivityPaginationRequest { private String deviceType; private List deviceIds; private String operationCode; + private int operationId; private String initiatedBy; private long since; private Operation.Type type; @@ -132,4 +133,12 @@ public class ActivityPaginationRequest { public void setEndTimestamp(long endTimestamp) { this.endTimestamp = endTimestamp; } + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/Activity.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/Activity.java index e001d72929..3c68fc74b2 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/Activity.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/operation/mgt/Activity.java @@ -49,6 +49,14 @@ public class Activity { @JsonProperty("code") private String code; + @ApiModelProperty( + name = "operationId", + value = "Operation Id", + required = false, + example = "10") + @JsonProperty("operationId") + private int operationId; + @ApiModelProperty( name = "type", value = "Activity type", @@ -122,6 +130,14 @@ public class Activity { this.code = code; } + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + public Type getType() { return type; } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java index ff071365c6..5f95cbb62a 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/impl/GenericOperationDAOImpl.java @@ -2233,6 +2233,9 @@ public class GenericOperationDAOImpl implements OperationDAO { } sql.append("?) "); } + if (activityPaginationRequest.getOperationId() > 0) { + sql.append("AND OPERATION_ID = ? "); + } if (activityPaginationRequest.getOperationCode() != null) { sql.append("AND OPERATION_CODE = ? "); } @@ -2269,6 +2272,9 @@ public class GenericOperationDAOImpl implements OperationDAO { if (activityPaginationRequest.getOperationCode() != null) { sql.append("AND eom.OPERATION_CODE = ? "); } + if (activityPaginationRequest.getOperationId() > 0) { + sql.append("AND eom.OPERATION_ID = ? "); + } if (activityPaginationRequest.getInitiatedBy() != null) { sql.append("AND eom.INITIATED_BY = ? "); } @@ -2301,6 +2307,9 @@ public class GenericOperationDAOImpl implements OperationDAO { if (activityPaginationRequest.getOperationCode() != null) { stmt.setString(index++, activityPaginationRequest.getOperationCode()); } + if (activityPaginationRequest.getOperationId() > 0) { + stmt.setInt(index++, activityPaginationRequest.getOperationId()); + } if (activityPaginationRequest.getInitiatedBy() != null) { stmt.setString(index++, activityPaginationRequest.getInitiatedBy()); } @@ -2333,6 +2342,9 @@ public class GenericOperationDAOImpl implements OperationDAO { if (activityPaginationRequest.getOperationCode() != null) { stmt.setString(index++, activityPaginationRequest.getOperationCode()); } + if (activityPaginationRequest.getOperationId() > 0) { + stmt.setInt(index++, activityPaginationRequest.getOperationId()); + } if (activityPaginationRequest.getInitiatedBy() != null) { stmt.setString(index++, activityPaginationRequest.getInitiatedBy()); } @@ -2390,6 +2402,9 @@ public class GenericOperationDAOImpl implements OperationDAO { if (activityPaginationRequest.getOperationCode() != null) { sql.append("AND OPERATION_CODE = ? "); } + if (activityPaginationRequest.getOperationId() > 0) { + sql.append("AND OPERATION_ID = ? "); + } if (activityPaginationRequest.getInitiatedBy() != null) { sql.append("AND INITIATED_BY = ? "); } @@ -2421,6 +2436,9 @@ public class GenericOperationDAOImpl implements OperationDAO { if (activityPaginationRequest.getOperationCode() != null) { stmt.setString(index++, activityPaginationRequest.getOperationCode()); } + if (activityPaginationRequest.getOperationId() > 0) { + stmt.setInt(index++, activityPaginationRequest.getOperationId()); + } if (activityPaginationRequest.getInitiatedBy() != null) { stmt.setString(index++, activityPaginationRequest.getInitiatedBy()); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java index 273ec5c089..178cf8f8b3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/operation/mgt/dao/util/OperationDAOUtil.java @@ -248,6 +248,7 @@ public class OperationDAOUtil { activity.setCreatedTimeStamp( new java.util.Date(rs.getLong(("CREATED_TIMESTAMP")) * 1000).toString()); activity.setCode(rs.getString("OPERATION_CODE")); + activity.setOperationId(rs.getInt("OPERATION_ID")); activity.setInitiatedBy(rs.getString("INITIATED_BY")); DeviceIdentifier deviceIdentifier = new DeviceIdentifier();