Fixed header and tests
This commit is contained in:
		
							parent
							
								
									03f0bf5865
								
							
						
					
					
						commit
						613ebc9065
					
				@ -107,7 +107,7 @@ coap:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Cassandra driver configuration parameters
 | 
					# Cassandra driver configuration parameters
 | 
				
			||||||
cassandra:
 | 
					cassandra:
 | 
				
			||||||
  enabled: "${CASSANDRA_ENABLED:false}"
 | 
					  enabled: "${CASSANDRA_ENABLED:true}"
 | 
				
			||||||
  # Thingsboard cluster name
 | 
					  # Thingsboard cluster name
 | 
				
			||||||
  cluster_name: "${CASSANDRA_CLUSTER_NAME:Thingsboard Cluster}"
 | 
					  cluster_name: "${CASSANDRA_CLUSTER_NAME:Thingsboard Cluster}"
 | 
				
			||||||
  # Thingsboard keyspace name
 | 
					  # Thingsboard keyspace name
 | 
				
			||||||
@ -226,7 +226,7 @@ spring.mvc.cors:
 | 
				
			|||||||
         
 | 
					         
 | 
				
			||||||
# SQL DAO Configuration
 | 
					# SQL DAO Configuration
 | 
				
			||||||
sql:
 | 
					sql:
 | 
				
			||||||
  enabled: "${SQL_ENABLED:true}"
 | 
					  enabled: "${SQL_ENABLED:false}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
spring:
 | 
					spring:
 | 
				
			||||||
  data:
 | 
					  data:
 | 
				
			||||||
@ -244,3 +244,6 @@ spring:
 | 
				
			|||||||
    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
 | 
					    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
 | 
				
			||||||
    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
 | 
					    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
 | 
				
			||||||
    password: "${SPRING_DATASOURCE_PASSWORD:postgres}"
 | 
					    password: "${SPRING_DATASOURCE_PASSWORD:postgres}"
 | 
				
			||||||
 | 
					  autoconfigure:
 | 
				
			||||||
 | 
					    exclude:
 | 
				
			||||||
 | 
					      - org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
 | 
				
			||||||
@ -1 +1,3 @@
 | 
				
			|||||||
updates.enabled=false
 | 
					updates.enabled=false
 | 
				
			||||||
 | 
					cassandra.enabled=true
 | 
				
			||||||
 | 
					sql.enabled=false
 | 
				
			||||||
@ -48,6 +48,8 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao<
 | 
				
			|||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Transactional(propagation = REQUIRES_NEW)
 | 
					    @Transactional(propagation = REQUIRES_NEW)
 | 
				
			||||||
    public D save(D domain) {
 | 
					    public D save(D domain) {
 | 
				
			||||||
@ -80,7 +82,6 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao<
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<D> findByIdAsync(UUID key) {
 | 
					    public ListenableFuture<D> findByIdAsync(UUID key) {
 | 
				
			||||||
        log.debug("Get entity by key async {}", key);
 | 
					        log.debug("Get entity by key async {}", key);
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        ListenableFuture<D> listenableFuture = service.submit(() -> DaoUtil.getData(getCrudRepository().findOne(key)));
 | 
					        ListenableFuture<D> listenableFuture = service.submit(() -> DaoUtil.getData(getCrudRepository().findOne(key)));
 | 
				
			||||||
        return listenableFuture;
 | 
					        return listenableFuture;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -70,7 +70,6 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    @Transactional(propagation = REQUIRES_NEW)
 | 
					    @Transactional(propagation = REQUIRES_NEW)
 | 
				
			||||||
    public ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type) {
 | 
					    public ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type) {
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() -> DaoUtil.getData(
 | 
					        return service.submit(() -> DaoUtil.getData(
 | 
				
			||||||
                alarmRepository.findLatestByOriginatorAndType(tenantId.getId(), originator.getId(),
 | 
					                alarmRepository.findLatestByOriginatorAndType(tenantId.getId(), originator.getId(),
 | 
				
			||||||
                originator.getEntityType().ordinal(), type)));
 | 
					                originator.getEntityType().ordinal(), type)));
 | 
				
			||||||
 | 
				
			|||||||
@ -68,7 +68,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds) {
 | 
					    public ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds) {
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() ->
 | 
					        return service.submit(() ->
 | 
				
			||||||
                DaoUtil.convertDataList(assetRepository.findByTenantIdAndIdIn(tenantId, assetIds)));
 | 
					                DaoUtil.convertDataList(assetRepository.findByTenantIdAndIdIn(tenantId, assetIds)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -86,7 +85,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds) {
 | 
					    public ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds) {
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() ->
 | 
					        return service.submit(() ->
 | 
				
			||||||
                DaoUtil.convertDataList( assetRepository.findByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, assetIds)));
 | 
					                DaoUtil.convertDataList( assetRepository.findByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, assetIds)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -115,7 +113,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<TenantAssetType>> findTenantAssetTypesAsync() {
 | 
					    public ListenableFuture<List<TenantAssetType>> findTenantAssetTypesAsync() {
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() -> assetRepository.findTenantAssetTypes());
 | 
					        return service.submit(() -> assetRepository.findTenantAssetTypes());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,18 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Copyright © 2016-2017 The Thingsboard Authors
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
 | 
					 * You may obtain a copy of the License at
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 | 
					 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
 | 
					 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
 | 
					 * See the License for the specific language governing permissions and
 | 
				
			||||||
 | 
					 * limitations under the License.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
package org.thingsboard.server.dao.sql.attributes;
 | 
					package org.thingsboard.server.dao.sql.attributes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.datastax.driver.core.ResultSet;
 | 
					import com.datastax.driver.core.ResultSet;
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@
 | 
				
			|||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
 * You may obtain a copy of the License at
 | 
					 * You may obtain a copy of the License at
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
					 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Unless required by applicable law or agreed to in writing, software
 | 
					 * Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
@ -19,6 +19,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
				
			|||||||
import org.springframework.data.jpa.repository.Query;
 | 
					import org.springframework.data.jpa.repository.Query;
 | 
				
			||||||
import org.springframework.data.repository.CrudRepository;
 | 
					import org.springframework.data.repository.CrudRepository;
 | 
				
			||||||
import org.springframework.data.repository.query.Param;
 | 
					import org.springframework.data.repository.query.Param;
 | 
				
			||||||
 | 
					import org.thingsboard.server.common.data.TenantDeviceType;
 | 
				
			||||||
import org.thingsboard.server.dao.model.sql.DeviceEntity;
 | 
					import org.thingsboard.server.dao.model.sql.DeviceEntity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
@ -71,6 +72,9 @@ public interface DeviceRepository extends CrudRepository<DeviceEntity, UUID> {
 | 
				
			|||||||
                                                          @Param("textSearch") String textSearch,
 | 
					                                                          @Param("textSearch") String textSearch,
 | 
				
			||||||
                                                          @Param("idOffset") UUID idOffset);
 | 
					                                                          @Param("idOffset") UUID idOffset);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Query(nativeQuery = true, value = "SELECT DISTINCT TYPE, TENANT_ID FROM DEVICE")
 | 
				
			||||||
 | 
					    List<TenantDeviceType> findTenantDeviceTypes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    DeviceEntity findByTenantIdAndName(UUID tenantId, String name);
 | 
					    DeviceEntity findByTenantIdAndName(UUID tenantId, String name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    List<DeviceEntity> findDevicesByTenantIdAndCustomerIdAndIdIn(UUID tenantId, UUID customerId, List<UUID> deviceIds);
 | 
					    List<DeviceEntity> findDevicesByTenantIdAndCustomerIdAndIdIn(UUID tenantId, UUID customerId, List<UUID> deviceIds);
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,7 @@
 | 
				
			|||||||
 * you may not use this file except in compliance with the License.
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
 * You may obtain a copy of the License at
 | 
					 * You may obtain a copy of the License at
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * http://www.apache.org/licenses/LICENSE-2.0
 | 
					 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Unless required by applicable law or agreed to in writing, software
 | 
					 * Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
@ -16,8 +16,6 @@
 | 
				
			|||||||
package org.thingsboard.server.dao.sql.device;
 | 
					package org.thingsboard.server.dao.sql.device;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.google.common.util.concurrent.ListenableFuture;
 | 
					import com.google.common.util.concurrent.ListenableFuture;
 | 
				
			||||||
import com.google.common.util.concurrent.ListeningExecutorService;
 | 
					 | 
				
			||||||
import com.google.common.util.concurrent.MoreExecutors;
 | 
					 | 
				
			||||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
					import org.springframework.beans.factory.annotation.Autowired;
 | 
				
			||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
					import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
				
			||||||
import org.springframework.data.repository.CrudRepository;
 | 
					import org.springframework.data.repository.CrudRepository;
 | 
				
			||||||
@ -33,7 +31,6 @@ import org.thingsboard.server.dao.sql.JpaAbstractSearchTextDao;
 | 
				
			|||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Optional;
 | 
					import java.util.Optional;
 | 
				
			||||||
import java.util.UUID;
 | 
					import java.util.UUID;
 | 
				
			||||||
import java.util.concurrent.Executors;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
 | 
					import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -45,7 +42,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
 | 
				
			|||||||
public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao {
 | 
					public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device> implements DeviceDao {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Autowired
 | 
					    @Autowired
 | 
				
			||||||
    DeviceRepository deviceRepository;
 | 
					    private DeviceRepository deviceRepository;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected Class<DeviceEntity> getEntityClass() {
 | 
					    protected Class<DeviceEntity> getEntityClass() {
 | 
				
			||||||
@ -70,8 +67,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) {
 | 
					    public ListenableFuture<List<Device>> findDevicesByTenantIdAndIdsAsync(UUID tenantId, List<UUID> deviceIds) {
 | 
				
			||||||
        System.out.println(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds).size());
 | 
					 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds)));
 | 
					        return service.submit(() -> DaoUtil.convertDataList(deviceRepository.findDevicesByTenantIdAndIdIn(tenantId, deviceIds)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -89,7 +84,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds) {
 | 
					    public ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds) {
 | 
				
			||||||
        ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
 | 
					 | 
				
			||||||
        return service.submit(() -> DaoUtil.convertDataList(
 | 
					        return service.submit(() -> DaoUtil.convertDataList(
 | 
				
			||||||
                deviceRepository.findDevicesByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, deviceIds)));
 | 
					                deviceRepository.findDevicesByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, deviceIds)));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -127,7 +121,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public ListenableFuture<List<TenantDeviceType>> findTenantDeviceTypesAsync() {
 | 
					    public ListenableFuture<List<TenantDeviceType>> findTenantDeviceTypesAsync() {
 | 
				
			||||||
        //TODO
 | 
					        return service.submit(() -> deviceRepository.findTenantDeviceTypes());
 | 
				
			||||||
        return null;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,3 +1,18 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Copyright © 2016-2017 The Thingsboard Authors
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
 | 
					 * You may obtain a copy of the License at
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 | 
					 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
 | 
					 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
 | 
					 * See the License for the specific language governing permissions and
 | 
				
			||||||
 | 
					 * limitations under the License.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
package org.thingsboard.server.dao.sql.timeseries;
 | 
					package org.thingsboard.server.dao.sql.timeseries;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.datastax.driver.core.ResultSetFuture;
 | 
					import com.datastax.driver.core.ResultSetFuture;
 | 
				
			||||||
 | 
				
			|||||||
@ -13,6 +13,7 @@
 | 
				
			|||||||
-- See the License for the specific language governing permissions and
 | 
					-- See the License for the specific language governing permissions and
 | 
				
			||||||
-- limitations under the License.
 | 
					-- limitations under the License.
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SET statement_timeout = 0;
 | 
					SET statement_timeout = 0;
 | 
				
			||||||
SET lock_timeout = 0;
 | 
					SET lock_timeout = 0;
 | 
				
			||||||
SET idle_in_transaction_session_timeout = 0;
 | 
					SET idle_in_transaction_session_timeout = 0;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								pom.xml
									
									
									
									
									
								
							@ -455,6 +455,7 @@
 | 
				
			|||||||
                <groupId>com.github.springtestdbunit</groupId>
 | 
					                <groupId>com.github.springtestdbunit</groupId>
 | 
				
			||||||
                <artifactId>spring-test-dbunit</artifactId>
 | 
					                <artifactId>spring-test-dbunit</artifactId>
 | 
				
			||||||
                <version>${spring-test-dbunit.version}</version>
 | 
					                <version>${spring-test-dbunit.version}</version>
 | 
				
			||||||
 | 
					                <scope>test</scope>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>io.jsonwebtoken</groupId>
 | 
					                <groupId>io.jsonwebtoken</groupId>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user