@ -17,6 +17,9 @@ package org.thingsboard.server.common.data;
import com.fasterxml.jackson.annotation.JsonIgnore ;
import com.fasterxml.jackson.core.JsonProcessingException ;
import com.fasterxml.jackson.databind.JsonNode ;
import io.swagger.annotations.ApiModel ;
import io.swagger.annotations.ApiModelProperty ;
import lombok.EqualsAndHashCode ;
import lombok.extern.slf4j.Slf4j ;
import org.thingsboard.server.common.data.device.data.DeviceData ;
@ -31,6 +34,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException ;
import java.util.Optional ;
@ApiModel
@EqualsAndHashCode ( callSuper = true )
@Slf4j
public class Device extends SearchTextBasedWithAdditionalInfo < DeviceId > implements HasName , HasTenantId , HasCustomerId , HasOtaPackage {
@ -88,6 +92,22 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
return this ;
}
@ApiModelProperty ( position = 1 , value = "JSON object with the device Id. " +
"Specify this field to update the device. " +
"Referencing non-existing device Id will cause error. " +
"Omit this field to create new device." )
@Override
public DeviceId getId ( ) {
return super . getId ( ) ;
}
@ApiModelProperty ( position = 2 , value = "Timestamp of the device creation, in milliseconds" , example = "1609459200000" , readOnly = true )
@Override
public long getCreatedTime ( ) {
return super . getCreatedTime ( ) ;
}
@ApiModelProperty ( position = 3 , value = "JSON object with Tenant Id. Use 'assignDeviceToTenant' to change the Tenant Id." , readOnly = true )
public TenantId getTenantId ( ) {
return tenantId ;
}
@ -96,6 +116,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . tenantId = tenantId ;
}
@ApiModelProperty ( position = 4 , value = "JSON object with Customer Id. Use 'assignDeviceToCustomer' to change the Customer Id." , readOnly = true )
public CustomerId getCustomerId ( ) {
return customerId ;
}
@ -104,6 +125,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . customerId = customerId ;
}
@ApiModelProperty ( position = 5 , required = true , value = "Unique Device Name in scope of Tenant" , example = "A4B72CCDFF33" )
@Override
public String getName ( ) {
return name ;
@ -113,6 +135,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . name = name ;
}
@ApiModelProperty ( position = 6 , required = true , value = "Device Profile Name" , example = "Temperature Sensor" )
public String getType ( ) {
return type ;
}
@ -121,6 +144,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . type = type ;
}
@ApiModelProperty ( position = 7 , required = true , value = "Label that may be used in widgets" , example = "Room 234 Sensor" )
public String getLabel ( ) {
return label ;
}
@ -129,6 +153,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . label = label ;
}
@ApiModelProperty ( position = 8 , required = true , value = "JSON object with Device Profile Id." )
public DeviceProfileId getDeviceProfileId ( ) {
return deviceProfileId ;
}
@ -137,6 +162,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . deviceProfileId = deviceProfileId ;
}
@ApiModelProperty ( position = 9 , value = "JSON object with content specific to type of transport in the device profile." )
public DeviceData getDeviceData ( ) {
if ( deviceData ! = null ) {
return deviceData ;
@ -169,6 +195,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
return getName ( ) ;
}
@ApiModelProperty ( position = 10 , value = "JSON object with Ota Package Id." )
public OtaPackageId getFirmwareId ( ) {
return firmwareId ;
}
@ -177,6 +204,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . firmwareId = firmwareId ;
}
@ApiModelProperty ( position = 11 , value = "JSON object with Ota Package Id." )
public OtaPackageId getSoftwareId ( ) {
return softwareId ;
}
@ -185,6 +213,12 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen
this . softwareId = softwareId ;
}
@ApiModelProperty ( position = 12 , value = "Additional parameters of the device" , dataType = "com.fasterxml.jackson.databind.JsonNode" )
@Override
public JsonNode getAdditionalInfo ( ) {
return super . getAdditionalInfo ( ) ;
}
@Override
public String toString ( ) {
StringBuilder builder = new StringBuilder ( ) ;