Fixed header and tests
This commit is contained in:
parent
03f0bf5865
commit
613ebc9065
@ -107,7 +107,7 @@ coap:
|
||||
|
||||
# Cassandra driver configuration parameters
|
||||
cassandra:
|
||||
enabled: "${CASSANDRA_ENABLED:false}"
|
||||
enabled: "${CASSANDRA_ENABLED:true}"
|
||||
# Thingsboard cluster name
|
||||
cluster_name: "${CASSANDRA_CLUSTER_NAME:Thingsboard Cluster}"
|
||||
# Thingsboard keyspace name
|
||||
@ -226,7 +226,7 @@ spring.mvc.cors:
|
||||
|
||||
# SQL DAO Configuration
|
||||
sql:
|
||||
enabled: "${SQL_ENABLED:true}"
|
||||
enabled: "${SQL_ENABLED:false}"
|
||||
|
||||
spring:
|
||||
data:
|
||||
@ -243,4 +243,7 @@ spring:
|
||||
driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}"
|
||||
url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
|
||||
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;
|
||||
}
|
||||
|
||||
protected ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRES_NEW)
|
||||
public D save(D domain) {
|
||||
@ -80,7 +82,6 @@ public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao<
|
||||
@Override
|
||||
public ListenableFuture<D> findByIdAsync(UUID 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)));
|
||||
return listenableFuture;
|
||||
}
|
||||
|
||||
@ -70,7 +70,6 @@ public class JpaAlarmDao extends JpaAbstractDao<AlarmEntity, Alarm> implements A
|
||||
@Override
|
||||
@Transactional(propagation = REQUIRES_NEW)
|
||||
public ListenableFuture<Alarm> findLatestByOriginatorAndType(TenantId tenantId, EntityId originator, String type) {
|
||||
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
return service.submit(() -> DaoUtil.getData(
|
||||
alarmRepository.findLatestByOriginatorAndType(tenantId.getId(), originator.getId(),
|
||||
originator.getEntityType().ordinal(), type)));
|
||||
|
||||
@ -68,7 +68,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<Asset>> findAssetsByTenantIdAndIdsAsync(UUID tenantId, List<UUID> assetIds) {
|
||||
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
return service.submit(() ->
|
||||
DaoUtil.convertDataList(assetRepository.findByTenantIdAndIdIn(tenantId, assetIds)));
|
||||
}
|
||||
@ -86,7 +85,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<Asset>> findAssetsByTenantIdAndCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> assetIds) {
|
||||
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
return service.submit(() ->
|
||||
DaoUtil.convertDataList( assetRepository.findByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, assetIds)));
|
||||
}
|
||||
@ -115,7 +113,6 @@ public class JpaAssetDao extends JpaAbstractSearchTextDao<AssetEntity, Asset> im
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<TenantAssetType>> findTenantAssetTypesAsync() {
|
||||
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
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;
|
||||
|
||||
import com.datastax.driver.core.ResultSet;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@ -19,6 +19,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.thingsboard.server.common.data.TenantDeviceType;
|
||||
import org.thingsboard.server.dao.model.sql.DeviceEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -71,6 +72,9 @@ public interface DeviceRepository extends CrudRepository<DeviceEntity, UUID> {
|
||||
@Param("textSearch") String textSearch,
|
||||
@Param("idOffset") UUID idOffset);
|
||||
|
||||
@Query(nativeQuery = true, value = "SELECT DISTINCT TYPE, TENANT_ID FROM DEVICE")
|
||||
List<TenantDeviceType> findTenantDeviceTypes();
|
||||
|
||||
DeviceEntity findByTenantIdAndName(UUID tenantId, String name);
|
||||
|
||||
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 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
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -16,8 +16,6 @@
|
||||
package org.thingsboard.server.dao.sql.device;
|
||||
|
||||
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.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@ -33,7 +31,6 @@ import org.thingsboard.server.dao.sql.JpaAbstractSearchTextDao;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
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 {
|
||||
|
||||
@Autowired
|
||||
DeviceRepository deviceRepository;
|
||||
private DeviceRepository deviceRepository;
|
||||
|
||||
@Override
|
||||
protected Class<DeviceEntity> getEntityClass() {
|
||||
@ -70,8 +67,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
|
||||
|
||||
@Override
|
||||
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)));
|
||||
}
|
||||
|
||||
@ -89,7 +84,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<Device>> findDevicesByTenantIdCustomerIdAndIdsAsync(UUID tenantId, UUID customerId, List<UUID> deviceIds) {
|
||||
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
|
||||
return service.submit(() -> DaoUtil.convertDataList(
|
||||
deviceRepository.findDevicesByTenantIdAndCustomerIdAndIdIn(tenantId, customerId, deviceIds)));
|
||||
}
|
||||
@ -127,7 +121,6 @@ public class JpaDeviceDao extends JpaAbstractSearchTextDao<DeviceEntity, Device>
|
||||
|
||||
@Override
|
||||
public ListenableFuture<List<TenantDeviceType>> findTenantDeviceTypesAsync() {
|
||||
//TODO
|
||||
return null;
|
||||
return service.submit(() -> deviceRepository.findTenantDeviceTypes());
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
import com.datastax.driver.core.ResultSetFuture;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
--
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
SET idle_in_transaction_session_timeout = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user