Add supported operations param to subtype

default-scope-updating-issue
Charitha Goonetilleke 4 months ago
parent fa24f95a69
commit 57e05b4ca9

@ -72,7 +72,7 @@ public class DAOUtil {
deviceSubType = loadDeviceSubType(rs); deviceSubType = loadDeviceSubType(rs);
} }
if (operationCode != null) { if (operationCode != null) {
deviceSubType.addOperationCode(operationCode); deviceSubType.addSupportedOperation(operationCode);
} }
deviceSubTypes.put(key, deviceSubType); deviceSubTypes.put(key, deviceSubType);
} }

@ -24,7 +24,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
public abstract class DeviceSubType { public abstract class DeviceSubType {
private String subTypeId; private String subTypeId;
@ -32,22 +31,22 @@ public abstract class DeviceSubType {
private String deviceType; private String deviceType;
private String subTypeName; private String subTypeName;
private String typeDefinition; private String typeDefinition;
private Set<String> operationCodes = new HashSet<>(); private final Set<String> supportedOperations = new HashSet<>();
public DeviceSubType() { public DeviceSubType() {
} }
public DeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition, public DeviceSubType(String subTypeId, int tenantId, String deviceType,
Set<String> operationCodes) { String subTypeName, String typeDefinition,
Set<String> supportedOperations) {
this.subTypeId = subTypeId; this.subTypeId = subTypeId;
this.tenantId = tenantId; this.tenantId = tenantId;
this.deviceType = deviceType; this.deviceType = deviceType;
this.subTypeName = subTypeName; this.subTypeName = subTypeName;
this.typeDefinition = typeDefinition; this.typeDefinition = typeDefinition;
if (operationCodes != null || !operationCodes.isEmpty()) { if (supportedOperations != null && !supportedOperations.isEmpty()) {
this.operationCodes.addAll(operationCodes); this.supportedOperations.addAll(supportedOperations);
} }
} }
public String getSubTypeId() { public String getSubTypeId() {
@ -94,10 +93,16 @@ public abstract class DeviceSubType {
public abstract String parseSubTypeToJson() throws JsonProcessingException; public abstract String parseSubTypeToJson() throws JsonProcessingException;
public void addOperationCode(String code) { public void setSupportedOperations(Set<String> supportedOperations) {
operationCodes.add(code); this.supportedOperations.addAll(supportedOperations);
} }
public Set<String> getOperationCodes() {
return operationCodes; public void addSupportedOperation(String code) {
supportedOperations.add(code);
} }
public Set<String> getSupportedOperations() {
return supportedOperations;
}
} }

Loading…
Cancel
Save