@ -51,7 +51,6 @@ import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
import org.thingsboard.server.common.data.kv.BooleanDataEntry ;
import org.thingsboard.server.common.data.kv.DoubleDataEntry ;
import org.thingsboard.server.common.data.kv.LongDataEntry ;
import org.thingsboard.server.common.data.page.PageLink ;
import org.thingsboard.server.common.data.query.BooleanFilterPredicate ;
import org.thingsboard.server.common.data.query.DynamicValue ;
import org.thingsboard.server.common.data.query.DynamicValueSourceType ;
@ -73,7 +72,6 @@ import org.thingsboard.server.dao.device.DeviceCredentialsService;
import org.thingsboard.server.dao.device.DeviceProfileService ;
import org.thingsboard.server.dao.device.DeviceService ;
import org.thingsboard.server.dao.exception.DataValidationException ;
import org.thingsboard.server.dao.rule.RuleChainService ;
import org.thingsboard.server.dao.settings.AdminSettingsService ;
import org.thingsboard.server.dao.tenant.TenantProfileService ;
import org.thingsboard.server.dao.tenant.TenantService ;
@ -129,9 +127,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
@Autowired
private DeviceCredentialsService deviceCredentialsService ;
@Autowired
private RuleChainService ruleChainService ;
@Bean
protected BCryptPasswordEncoder passwordEncoder ( ) {
return new BCryptPasswordEncoder ( ) ;
@ -271,8 +266,6 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
thermostatDeviceProfile . setTransportType ( DeviceTransportType . DEFAULT ) ;
thermostatDeviceProfile . setProvisionType ( DeviceProfileProvisionType . DISABLED ) ;
thermostatDeviceProfile . setDescription ( "Thermostat device profile" ) ;
thermostatDeviceProfile . setDefaultRuleChainId ( ruleChainService . findTenantRuleChains (
demoTenant . getId ( ) , new PageLink ( 1 , 0 , "Thermostat Alarms" ) ) . getData ( ) . get ( 0 ) . getId ( ) ) ;
DeviceProfileData deviceProfileData = new DeviceProfileData ( ) ;
DefaultDeviceProfileConfiguration configuration = new DefaultDeviceProfileConfiguration ( ) ;
@ -290,13 +283,13 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
AlarmCondition temperatureCondition = new AlarmCondition ( ) ;
temperatureCondition . setSpec ( new SimpleAlarmConditionSpec ( ) ) ;
KeyFilter alarmTemperature AttributeFilter = new KeyFilter ( ) ;
alarmTemperature AttributeFilter. setKey ( new EntityKey ( EntityKeyType . ATTRIBUTE , "alarmTemperature " ) ) ;
alarmTemperature AttributeFilter. setValueType ( EntityKeyValueType . BOOLEAN ) ;
BooleanFilterPredicate alarmTemperature AttributePredicate = new BooleanFilterPredicate ( ) ;
alarmTemperature AttributePredicate. setOperation ( BooleanFilterPredicate . BooleanOperation . EQUAL ) ;
alarmTemperature AttributePredicate. setValue ( new FilterPredicateValue < > ( Boolean . TRUE ) ) ;
alarmTemperature AttributeFilter. setPredicate ( alarmTemperature AttributePredicate) ;
KeyFilter temperatureAlarmFlag AttributeFilter = new KeyFilter ( ) ;
temperatureAlarmFlag AttributeFilter. setKey ( new EntityKey ( EntityKeyType . ATTRIBUTE , "temperatureAlarmFlag " ) ) ;
temperatureAlarmFlag AttributeFilter. setValueType ( EntityKeyValueType . BOOLEAN ) ;
BooleanFilterPredicate temperatureAlarmFlag AttributePredicate = new BooleanFilterPredicate ( ) ;
temperatureAlarmFlag AttributePredicate. setOperation ( BooleanFilterPredicate . BooleanOperation . EQUAL ) ;
temperatureAlarmFlag AttributePredicate. setValue ( new FilterPredicateValue < > ( Boolean . TRUE ) ) ;
temperatureAlarmFlag AttributeFilter. setPredicate ( temperatureAlarmFlag AttributePredicate) ;
KeyFilter temperatureTimeseriesFilter = new KeyFilter ( ) ;
temperatureTimeseriesFilter . setKey ( new EntityKey ( EntityKeyType . TIME_SERIES , "temperature" ) ) ;
@ -305,10 +298,10 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
temperatureTimeseriesFilterPredicate . setOperation ( NumericFilterPredicate . NumericOperation . GREATER ) ;
FilterPredicateValue < Double > temperatureTimeseriesPredicateValue =
new FilterPredicateValue < > ( 25 . 0 , null ,
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "thresholdT emperature" ) ) ;
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "temperatureAlarmThreshold " ) ) ;
temperatureTimeseriesFilterPredicate . setValue ( temperatureTimeseriesPredicateValue ) ;
temperatureTimeseriesFilter . setPredicate ( temperatureTimeseriesFilterPredicate ) ;
temperatureCondition . setCondition ( Arrays . asList ( alarmTemperature AttributeFilter, temperatureTimeseriesFilter ) ) ;
temperatureCondition . setCondition ( Arrays . asList ( temperatureAlarmFlag AttributeFilter, temperatureTimeseriesFilter ) ) ;
temperatureRule . setAlarmDetails ( "Current temperature = ${temperature}" ) ;
temperatureRule . setCondition ( temperatureCondition ) ;
highTemperature . setCreateRules ( new LinkedHashMap < > ( Collections . singletonMap ( AlarmSeverity . MAJOR , temperatureRule ) ) ) ;
@ -324,7 +317,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
clearTemperatureTimeseriesFilterPredicate . setOperation ( NumericFilterPredicate . NumericOperation . LESS_OR_EQUAL ) ;
FilterPredicateValue < Double > clearTemperatureTimeseriesPredicateValue =
new FilterPredicateValue < > ( 25 . 0 , null ,
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "thresholdT emperature" ) ) ;
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "temperatureAlarmThreshold " ) ) ;
clearTemperatureTimeseriesFilterPredicate . setValue ( clearTemperatureTimeseriesPredicateValue ) ;
clearTemperatureTimeseriesFilter . setPredicate ( clearTemperatureTimeseriesFilterPredicate ) ;
@ -340,13 +333,13 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
AlarmCondition humidityCondition = new AlarmCondition ( ) ;
humidityCondition . setSpec ( new SimpleAlarmConditionSpec ( ) ) ;
KeyFilter alarmHumidity AttributeFilter = new KeyFilter ( ) ;
alarmHumidity AttributeFilter. setKey ( new EntityKey ( EntityKeyType . ATTRIBUTE , "alarmHumidity " ) ) ;
alarmHumidity AttributeFilter. setValueType ( EntityKeyValueType . BOOLEAN ) ;
BooleanFilterPredicate alarmHumidity AttributePredicate = new BooleanFilterPredicate ( ) ;
alarmHumidity AttributePredicate. setOperation ( BooleanFilterPredicate . BooleanOperation . EQUAL ) ;
alarmHumidity AttributePredicate. setValue ( new FilterPredicateValue < > ( Boolean . TRUE ) ) ;
alarmHumidity AttributeFilter. setPredicate ( alarmHumidity AttributePredicate) ;
KeyFilter humidityAlarmFlag AttributeFilter = new KeyFilter ( ) ;
humidityAlarmFlag AttributeFilter. setKey ( new EntityKey ( EntityKeyType . ATTRIBUTE , "humidityAlarmFlag " ) ) ;
humidityAlarmFlag AttributeFilter. setValueType ( EntityKeyValueType . BOOLEAN ) ;
BooleanFilterPredicate humidityAlarmFlag AttributePredicate = new BooleanFilterPredicate ( ) ;
humidityAlarmFlag AttributePredicate. setOperation ( BooleanFilterPredicate . BooleanOperation . EQUAL ) ;
humidityAlarmFlag AttributePredicate. setValue ( new FilterPredicateValue < > ( Boolean . TRUE ) ) ;
humidityAlarmFlag AttributeFilter. setPredicate ( humidityAlarmFlag AttributePredicate) ;
KeyFilter humidityTimeseriesFilter = new KeyFilter ( ) ;
humidityTimeseriesFilter . setKey ( new EntityKey ( EntityKeyType . TIME_SERIES , "humidity" ) ) ;
@ -355,10 +348,10 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
humidityTimeseriesFilterPredicate . setOperation ( NumericFilterPredicate . NumericOperation . LESS ) ;
FilterPredicateValue < Double > humidityTimeseriesPredicateValue =
new FilterPredicateValue < > ( 60 . 0 , null ,
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "thresholdHumidity " ) ) ;
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "humidi tyAlarmT hreshold" ) ) ;
humidityTimeseriesFilterPredicate . setValue ( humidityTimeseriesPredicateValue ) ;
humidityTimeseriesFilter . setPredicate ( humidityTimeseriesFilterPredicate ) ;
humidityCondition . setCondition ( Arrays . asList ( alarmHumidity AttributeFilter, humidityTimeseriesFilter ) ) ;
humidityCondition . setCondition ( Arrays . asList ( humidityAlarmFlag AttributeFilter, humidityTimeseriesFilter ) ) ;
humidityRule . setCondition ( humidityCondition ) ;
humidityRule . setAlarmDetails ( "Current humidity = ${humidity}" ) ;
@ -375,7 +368,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
clearHumidityTimeseriesFilterPredicate . setOperation ( NumericFilterPredicate . NumericOperation . GREATER_OR_EQUAL ) ;
FilterPredicateValue < Double > clearHumidityTimeseriesPredicateValue =
new FilterPredicateValue < > ( 60 . 0 , null ,
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "thresholdHumidity " ) ) ;
new DynamicValue < > ( DynamicValueSourceType . CURRENT_DEVICE , "humidi tyAlarmT hreshold" ) ) ;
clearHumidityTimeseriesFilterPredicate . setValue ( clearHumidityTimeseriesPredicateValue ) ;
clearHumidityTimeseriesFilter . setPredicate ( clearHumidityTimeseriesFilterPredicate ) ;
@ -394,18 +387,18 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
attributesService . save ( demoTenant . getId ( ) , t1Id , DataConstants . SERVER_SCOPE ,
Arrays . asList ( new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new DoubleDataEntry ( "latitude" , 37 . 3948 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new DoubleDataEntry ( "longitude" , - 122 . 1503 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "alarmTemperature " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "alarmHumidity " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "thresholdT emperature" , ( long ) 20 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "thresholdHumidity " , ( long ) 50 ) ) ) ) ;
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "temperatureAlarmFlag " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "humidityAlarmFlag " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "temperatureAlarmThreshold " , ( long ) 20 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "humidi tyAlarmT hreshold" , ( long ) 50 ) ) ) ) ;
attributesService . save ( demoTenant . getId ( ) , t2Id , DataConstants . SERVER_SCOPE ,
Arrays . asList ( new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new DoubleDataEntry ( "latitude" , 37 . 493801 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new DoubleDataEntry ( "longitude" , - 121 . 948769 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "alarmTemperature " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "alarmHumidity " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "thresholdT emperature" , ( long ) 25 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "thresholdHumidity " , ( long ) 30 ) ) ) ) ;
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "temperatureAlarmFlag " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new BooleanDataEntry ( "humidityAlarmFlag " , true ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "temperatureAlarmThreshold " , ( long ) 25 ) ) ,
new BaseAttributeKvEntry ( System . currentTimeMillis ( ) , new LongDataEntry ( "humidi tyAlarmT hreshold" , ( long ) 30 ) ) ) ) ;
installScripts . loadDashboards ( demoTenant . getId ( ) , null ) ;
}