From 57e05b4ca9b656a2f8bfd48ec37c846b39326cc0 Mon Sep 17 00:00:00 2001 From: Charitha Goonetilleke Date: Fri, 9 Aug 2024 09:14:33 +0530 Subject: [PATCH] Add supported operations param to subtype --- .../core/subtype/mgt/dao/util/DAOUtil.java | 2 +- .../core/subtype/mgt/dto/DeviceSubType.java | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java index f4569c6c36..3a1aa6fa67 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java @@ -72,7 +72,7 @@ public class DAOUtil { deviceSubType = loadDeviceSubType(rs); } if (operationCode != null) { - deviceSubType.addOperationCode(operationCode); + deviceSubType.addSupportedOperation(operationCode); } deviceSubTypes.put(key, deviceSubType); } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java index cc27bb592e..e52ed3dbd0 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java @@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import java.util.HashSet; import java.util.Set; - public abstract class DeviceSubType { private String subTypeId; @@ -32,22 +31,22 @@ public abstract class DeviceSubType { private String deviceType; private String subTypeName; private String typeDefinition; - private Set operationCodes = new HashSet<>(); + private final Set supportedOperations = new HashSet<>(); + public DeviceSubType() { } - public DeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition, - Set operationCodes) { + public DeviceSubType(String subTypeId, int tenantId, String deviceType, + String subTypeName, String typeDefinition, + Set supportedOperations) { this.subTypeId = subTypeId; this.tenantId = tenantId; this.deviceType = deviceType; this.subTypeName = subTypeName; this.typeDefinition = typeDefinition; - if (operationCodes != null || !operationCodes.isEmpty()) { - this.operationCodes.addAll(operationCodes); + if (supportedOperations != null && !supportedOperations.isEmpty()) { + this.supportedOperations.addAll(supportedOperations); } - - } public String getSubTypeId() { @@ -94,10 +93,16 @@ public abstract class DeviceSubType { public abstract String parseSubTypeToJson() throws JsonProcessingException; - public void addOperationCode(String code) { - operationCodes.add(code); + public void setSupportedOperations(Set supportedOperations) { + this.supportedOperations.addAll(supportedOperations); } - public Set getOperationCodes() { - return operationCodes; + + public void addSupportedOperation(String code) { + supportedOperations.add(code); } + + public Set getSupportedOperations() { + return supportedOperations; + } + }