Browse Source

Merge branch 'master' of github.com:thingsboard/thingsboard

pull/5503/head
Igor Kulikov 5 years ago
parent
commit
668f1dda2a
  1. 20
      application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java
  2. 15
      application/src/main/java/org/thingsboard/server/service/queue/processing/TbRuleEngineProcessingStrategyFactory.java
  3. 13
      common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/CoapTransportService.java
  4. 52
      common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/callback/CoapEfentoCallback.java
  5. 54
      common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/efento/CoapEfentoTransportResource.java
  6. 42
      dao/src/main/java/org/thingsboard/server/dao/sql/alarm/AlarmRepository.java
  7. 20
      dao/src/main/java/org/thingsboard/server/dao/sql/asset/AssetRepository.java
  8. 36
      dao/src/main/java/org/thingsboard/server/dao/sql/audit/AuditLogRepository.java
  9. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java
  10. 2
      dao/src/main/java/org/thingsboard/server/dao/sql/customer/CustomerRepository.java
  11. 10
      dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java
  12. 6
      dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceProfileRepository.java
  13. 30
      dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceRepository.java
  14. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeEventRepository.java
  15. 18
      dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeRepository.java
  16. 20
      dao/src/main/java/org/thingsboard/server/dao/sql/entityview/EntityViewRepository.java
  17. 2
      dao/src/main/java/org/thingsboard/server/dao/sql/event/EventRepository.java
  18. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/ota/OtaPackageInfoRepository.java
  19. 8
      dao/src/main/java/org/thingsboard/server/dao/sql/rule/RuleChainRepository.java
  20. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantProfileRepository.java
  21. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantRepository.java
  22. 4
      dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java
  23. 6
      dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java

20
application/src/main/java/org/thingsboard/server/service/install/update/DefaultDataUpdateService.java

@ -147,18 +147,24 @@ public class DefaultDataUpdateService implements DataUpdateService {
if (deviceProfile.getProfileData().has("alarms") &&
!deviceProfile.getProfileData().get("alarms").isNull()) {
boolean isUpdated = false;
JsonNode array = deviceProfile.getProfileData().get("alarms");
for (JsonNode node : array) {
if (node.has("createRules")) {
JsonNode createRules = node.get("createRules");
JsonNode alarms = deviceProfile.getProfileData().get("alarms");
for (JsonNode alarm : alarms) {
if (alarm.has("createRules")) {
JsonNode createRules = alarm.get("createRules");
for (AlarmSeverity severity : AlarmSeverity.values()) {
if (createRules.has(severity.name())) {
isUpdated = isUpdated || convertDeviceProfileAlarmRulesForVersion330(createRules.get(severity.name()).get("condition").get("spec"));
JsonNode spec = createRules.get(severity.name()).get("condition").get("spec");
if (convertDeviceProfileAlarmRulesForVersion330(spec)) {
isUpdated = true;
}
}
}
}
if (node.has("clearRule") && !node.get("clearRule").isNull()) {
isUpdated = isUpdated || convertDeviceProfileAlarmRulesForVersion330(node.get("clearRule").get("condition").get("spec"));
if (alarm.has("clearRule") && !alarm.get("clearRule").isNull()) {
JsonNode spec = alarm.get("clearRule").get("condition").get("spec");
if (convertDeviceProfileAlarmRulesForVersion330(spec)) {
isUpdated = true;
}
}
}
if (isUpdated) {

15
application/src/main/java/org/thingsboard/server/service/queue/processing/TbRuleEngineProcessingStrategyFactory.java

@ -17,6 +17,7 @@ package org.thingsboard.server.service.queue.processing;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.thingsboard.server.common.msg.TbMsg;
import org.thingsboard.server.common.msg.queue.TbMsgCallback;
import org.thingsboard.server.gen.transport.TransportProtos;
@ -77,6 +78,7 @@ public class TbRuleEngineProcessingStrategyFactory {
@Override
public TbRuleEngineProcessingDecision analyze(TbRuleEngineProcessingResult result) {
if (result.isSuccess()) {
log.trace("[{}] The result of the msg pack processing is successful, going to proceed with processing of the following msgs", queueName);
return new TbRuleEngineProcessingDecision(true, null);
} else {
if (retryCount == 0) {
@ -91,15 +93,28 @@ public class TbRuleEngineProcessingStrategyFactory {
log.debug("[{}] Skip reprocess of the rule engine pack due to max allowed failure percentage", queueName);
return new TbRuleEngineProcessingDecision(true, null);
} else {
log.debug("[{}] The result of msg pack processing is unsuccessful, checking unprocessed msgs and going to reprocess them", queueName);
ConcurrentMap<UUID, TbProtoQueueMsg<TransportProtos.ToRuleEngineMsg>> toReprocess = new ConcurrentHashMap<>(initialTotalCount);
if (retryFailed) {
result.getFailedMap().forEach(toReprocess::put);
} else if (log.isDebugEnabled() && !result.getFailedMap().isEmpty()) {
log.debug("[{}] Skipped {} failed messages due to the processing strategy configuration", queueName, result.getFailedMap().size());
}
if (retryTimeout) {
result.getPendingMap().forEach(toReprocess::put);
} else if (log.isDebugEnabled() && !result.getPendingMap().isEmpty()) {
log.debug("[{}] Skipped {} timedOut messages due to the processing strategy configuration", queueName, result.getPendingMap().size());
}
if (retrySuccessful) {
result.getSuccessMap().forEach(toReprocess::put);
} else if (log.isTraceEnabled() && !result.getSuccessMap().isEmpty()) {
log.trace("[{}] Skipped {} successful messages due to the processing strategy configuration", queueName, result.getSuccessMap().size());
}
if (CollectionUtils.isEmpty(toReprocess)) {
if (log.isDebugEnabled()) {
log.debug("[{}] Stopping the reprocessing logic due to reprocessing map is empty", queueName);
}
return new TbRuleEngineProcessingDecision(true, null);
}
log.debug("[{}] Going to reprocess {} messages", queueName, toReprocess.size());
if (log.isTraceEnabled()) {

13
common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/CoapTransportService.java

@ -39,7 +39,10 @@ public class CoapTransportService implements TbTransportService {
private static final String V1 = "v1";
private static final String API = "api";
private static final String EFENTO = "efento";
private static final String MEASUREMENTS = "m";
public static final String MEASUREMENTS = "m";
public static final String DEVICE_INFO = "i";
public static final String CONFIGURATION = "c";
public static final String CURRENT_TIMESTAMP = "t";
@Autowired
private CoapServerService coapServerService;
@ -56,9 +59,11 @@ public class CoapTransportService implements TbTransportService {
CoapResource api = new CoapResource(API);
api.add(new CoapTransportResource(coapTransportContext, coapServerService, V1));
CoapResource efento = new CoapResource(EFENTO);
CoapEfentoTransportResource efentoMeasurementsTransportResource = new CoapEfentoTransportResource(coapTransportContext, MEASUREMENTS);
efento.add(efentoMeasurementsTransportResource);
CoapEfentoTransportResource efento = new CoapEfentoTransportResource(coapTransportContext, EFENTO);
efento.add(new CoapResource(MEASUREMENTS));
efento.add(new CoapResource(DEVICE_INFO));
efento.add(new CoapResource(CONFIGURATION));
efento.add(new CoapResource(CURRENT_TIMESTAMP));
coapServer.add(api);
coapServer.add(efento);
coapServer.add(new OtaPackageTransportResource(coapTransportContext, OtaPackageType.FIRMWARE));

52
common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/callback/CoapEfentoCallback.java

@ -0,0 +1,52 @@
/**
* Copyright © 2016-2021 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.transport.coap.callback;
import org.eclipse.californium.core.coap.CoAP;
import org.eclipse.californium.core.coap.Response;
import org.eclipse.californium.core.server.resources.CoapExchange;
import org.thingsboard.server.common.transport.TransportServiceCallback;
public class CoapEfentoCallback implements TransportServiceCallback<Void> {
protected final CoapExchange exchange;
protected final CoAP.ResponseCode onSuccessResponse;
protected final CoAP.ResponseCode onFailureResponse;
public CoapEfentoCallback(CoapExchange exchange, CoAP.ResponseCode onSuccessResponse, CoAP.ResponseCode onFailureResponse) {
this.exchange = exchange;
this.onSuccessResponse = onSuccessResponse;
this.onFailureResponse = onFailureResponse;
}
@Override
public void onSuccess(Void msg) {
if (isConRequest()) {
Response response = new Response(onSuccessResponse);
response.setAcknowledged(true);
exchange.respond(response);
}
}
@Override
public void onError(Throwable e) {
exchange.respond(onFailureResponse);
}
protected boolean isConRequest() {
return exchange.advanced().getRequest().isConfirmable();
}
}

54
common/transport/coap/src/main/java/org/thingsboard/server/transport/coap/efento/CoapEfentoTransportResource.java

@ -21,6 +21,7 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.californium.core.coap.CoAP;
import org.eclipse.californium.core.coap.Request;
import org.eclipse.californium.core.coap.Response;
import org.eclipse.californium.core.network.Exchange;
import org.eclipse.californium.core.server.resources.CoapExchange;
import org.eclipse.californium.core.server.resources.Resource;
@ -38,9 +39,11 @@ import org.thingsboard.server.gen.transport.coap.MeasurementsProtos;
import org.thingsboard.server.transport.coap.AbstractCoapTransportResource;
import org.thingsboard.server.transport.coap.CoapTransportContext;
import org.thingsboard.server.transport.coap.callback.CoapDeviceAuthCallback;
import org.thingsboard.server.transport.coap.callback.CoapEfentoCallback;
import org.thingsboard.server.transport.coap.callback.CoapOkCallback;
import org.thingsboard.server.transport.coap.efento.utils.CoapEfentoUtils;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -48,11 +51,15 @@ import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import static org.thingsboard.server.transport.coap.CoapTransportService.CONFIGURATION;
import static org.thingsboard.server.transport.coap.CoapTransportService.CURRENT_TIMESTAMP;
import static org.thingsboard.server.transport.coap.CoapTransportService.DEVICE_INFO;
import static org.thingsboard.server.transport.coap.CoapTransportService.MEASUREMENTS;
@Slf4j
public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
private static final int MEASUREMENTS_POSITION = 2;
private static final String MEASUREMENTS = "m";
private static final int CHILD_RESOURCE_POSITION = 2;
public CoapEfentoTransportResource(CoapTransportContext context, String name) {
super(context, name);
@ -63,7 +70,17 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
@Override
protected void processHandleGet(CoapExchange exchange) {
exchange.respond(CoAP.ResponseCode.METHOD_NOT_ALLOWED);
Exchange advanced = exchange.advanced();
Request request = advanced.getRequest();
List<String> uriPath = request.getOptions().getUriPath();
boolean validPath = uriPath.size() == CHILD_RESOURCE_POSITION && uriPath.get(1).equals(CURRENT_TIMESTAMP);
if (!validPath) {
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
} else {
int dateInSec = (int) (System.currentTimeMillis() / 1000);
byte[] bytes = ByteBuffer.allocate(4).putInt(dateInSec).array();
exchange.respond(CoAP.ResponseCode.CONTENT, bytes);
}
}
@Override
@ -71,11 +88,30 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
Exchange advanced = exchange.advanced();
Request request = advanced.getRequest();
List<String> uriPath = request.getOptions().getUriPath();
boolean validPath = uriPath.size() == MEASUREMENTS_POSITION && uriPath.get(1).equals(MEASUREMENTS);
if (!validPath) {
if (uriPath.size() != CHILD_RESOURCE_POSITION) {
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
return;
}
String requestType = uriPath.get(1);
switch (requestType) {
case MEASUREMENTS:
processMeasurementsRequest(exchange, request);
break;
case DEVICE_INFO:
case CONFIGURATION:
Response response = new Response(CoAP.ResponseCode.CREATED);
if (exchange.advanced().getRequest().isConfirmable()) {
response.setAcknowledged(true);
exchange.respond(response);
}
break;
default:
exchange.respond(CoAP.ResponseCode.BAD_REQUEST);
break;
}
}
private void processMeasurementsRequest(CoapExchange exchange, Request request) {
byte[] bytes = request.getPayload();
try {
MeasurementsProtos.ProtoMeasurements protoMeasurements = MeasurementsProtos.ProtoMeasurements.parseFrom(bytes);
@ -90,7 +126,7 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
List<EfentoMeasurements> efentoMeasurements = getEfentoMeasurements(protoMeasurements, sessionId);
transportService.process(sessionInfo,
transportContext.getEfentoCoapAdaptor().convertToPostTelemetry(sessionId, efentoMeasurements),
new CoapOkCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
new CoapEfentoCallback(exchange, CoAP.ResponseCode.CREATED, CoAP.ResponseCode.INTERNAL_SERVER_ERROR));
reportSubscriptionInfo(sessionInfo, false, false);
} catch (AdaptorException e) {
log.error("[{}] Failed to decode Efento ProtoMeasurements: ", sessionId, e);
@ -168,6 +204,12 @@ public class CoapEfentoTransportResource extends AbstractCoapTransportResource {
values.addProperty("temperature_" + channel, ((double) (startPoint + sampleOffset)) / 10f);
startTimestampMillis = startTimestampMillis + measurementPeriodMillis;
break;
case WATER_METER:
values = valuesMap.computeIfAbsent(startTimestampMillis, k ->
CoapEfentoUtils.setDefaultMeasurements(serialNumber, batteryStatus, measurementPeriod, nextTransmissionAtMillis, signal, k));
values.addProperty("pulse_counter_water_" + channel, ((double) (startPoint + sampleOffset)));
startTimestampMillis = startTimestampMillis + measurementPeriodMillis;
break;
case HUMIDITY:
values = valuesMap.computeIfAbsent(startTimestampMillis, k ->
CoapEfentoUtils.setDefaultMeasurements(serialNumber, batteryStatus, measurementPeriod, nextTransmissionAtMillis, signal, k));

42
dao/src/main/java/org/thingsboard/server/dao/sql/alarm/AlarmRepository.java

@ -52,9 +52,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) "
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) "
,
countQuery = "" +
"SELECT count(a) + " + //alarms with relations only
@ -70,9 +70,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
" AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
" AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
" AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
" AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) " +
" AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) " +
" )" +
"FROM AlarmEntity a " +
"INNER JOIN RelationEntity re ON a.id = re.toId " +
@ -84,9 +84,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findAlarms(@Param("tenantId") UUID tenantId,
@Param("affectedEntityId") UUID affectedEntityId,
@Param("affectedEntityType") String affectedEntityType,
@ -101,9 +101,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ",
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ",
countQuery = "" +
"SELECT count(a) " +
"FROM AlarmEntity a " +
@ -111,9 +111,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findAllAlarms(@Param("tenantId") UUID tenantId,
@Param("startTime") Long startTime,
@Param("endTime") Long endTime,
@ -126,9 +126,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) "
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) "
,
countQuery = "" +
"SELECT count(a) " +
@ -137,9 +137,9 @@ public interface AlarmRepository extends CrudRepository<AlarmEntity, UUID> {
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:alarmStatuses) IS NULL OR a.status in (:alarmStatuses)) " +
"AND (LOWER(a.type) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT(:searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT(:searchText, '%'))) ")
"AND (LOWER(a.type) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.severity) LIKE LOWER(CONCAT('%', :searchText, '%')) " +
" OR LOWER(a.status) LIKE LOWER(CONCAT('%', :searchText, '%'))) ")
Page<AlarmInfoEntity> findCustomerAlarms(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("startTime") Long startTime,

20
dao/src/main/java/org/thingsboard/server/dao/sql/asset/AssetRepository.java

@ -39,7 +39,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
AssetInfoEntity findAssetInfoById(@Param("assetId") UUID assetId);
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -48,14 +48,14 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"FROM AssetEntity a " +
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("textSearch") String textSearch,
@ -66,7 +66,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -80,7 +80,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -91,7 +91,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -100,7 +100,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -113,7 +113,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -126,7 +126,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
@Query("SELECT a FROM AssetEntity a, RelationEntity re WHERE a.tenantId = :tenantId " +
"AND a.id = re.toId AND re.toType = 'ASSET' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -136,7 +136,7 @@ public interface AssetRepository extends PagingAndSortingRepository<AssetEntity,
"AND a.id = re.toId AND re.toType = 'ASSET' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<AssetEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

36
dao/src/main/java/org/thingsboard/server/dao/sql/audit/AuditLogRepository.java

@ -34,11 +34,11 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findByTenantId(
@Param("tenantId") UUID tenantId,
@ -54,10 +54,10 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityType") EntityType entityType,
@ -74,11 +74,11 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.userName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@ -94,10 +94,10 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE
"AND (:startTime IS NULL OR a.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR a.createdTime <= :endTime) " +
"AND ((:actionTypes) IS NULL OR a.actionType in (:actionTypes)) " +
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT(:textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT(:textSearch, '%')))"
"AND (LOWER(a.entityType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.entityName) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionType) LIKE LOWER(CONCAT('%', :textSearch, '%'))" +
"OR LOWER(a.actionStatus) LIKE LOWER(CONCAT('%', :textSearch, '%')))"
)
Page<AuditLogEntity> findAuditLogsByTenantIdAndUserId(@Param("tenantId") UUID tenantId,
@Param("userId") UUID userId,

4
dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java

@ -34,13 +34,13 @@ public interface ComponentDescriptorRepository extends PagingAndSortingRepositor
ComponentDescriptorEntity findByClazz(String clazz);
@Query("SELECT cd FROM ComponentDescriptorEntity cd WHERE cd.type = :type " +
"AND LOWER(cd.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(cd.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<ComponentDescriptorEntity> findByType(@Param("type") ComponentType type,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT cd FROM ComponentDescriptorEntity cd WHERE cd.type = :type " +
"AND cd.scope = :scope AND LOWER(cd.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND cd.scope = :scope AND LOWER(cd.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<ComponentDescriptorEntity> findByScopeAndType(@Param("type") ComponentType type,
@Param("scope") ComponentScope scope,
@Param("textSearch") String textSearch,

2
dao/src/main/java/org/thingsboard/server/dao/sql/customer/CustomerRepository.java

@ -30,7 +30,7 @@ import java.util.UUID;
public interface CustomerRepository extends PagingAndSortingRepository<CustomerEntity, UUID> {
@Query("SELECT c FROM CustomerEntity c WHERE c.tenantId = :tenantId " +
"AND LOWER(c.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(c.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<CustomerEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);

10
dao/src/main/java/org/thingsboard/server/dao/sql/dashboard/DashboardInfoRepository.java

@ -32,14 +32,14 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
DashboardInfoEntity findFirstByTenantIdAndTitle(UUID tenantId, String title);
@Query("SELECT di FROM DashboardInfoEntity di WHERE di.tenantId = :tenantId " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT di FROM DashboardInfoEntity di WHERE di.tenantId = :tenantId " +
"AND di.mobileHide = false " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findMobileByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@ -47,7 +47,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
@Query("SELECT di FROM DashboardInfoEntity di, RelationEntity re WHERE di.tenantId = :tenantId " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'DASHBOARD' " +
"AND re.relationType = 'Contains' AND re.fromId = :customerId AND re.fromType = 'CUSTOMER' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -57,7 +57,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
"AND di.mobileHide = false " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'DASHBOARD' " +
"AND re.relationType = 'Contains' AND re.fromId = :customerId AND re.fromType = 'CUSTOMER' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findMobileByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -66,7 +66,7 @@ public interface DashboardInfoRepository extends PagingAndSortingRepository<Dash
@Query("SELECT di FROM DashboardInfoEntity di, RelationEntity re WHERE di.tenantId = :tenantId " +
"AND di.id = re.toId AND re.toType = 'DASHBOARD' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(di.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(di.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DashboardInfoEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,

6
dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceProfileRepository.java

@ -35,21 +35,21 @@ public interface DeviceProfileRepository extends JpaRepository<DeviceProfileEnti
DeviceProfileInfo findDeviceProfileInfoById(@Param("deviceProfileId") UUID deviceProfileId);
@Query("SELECT d FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileEntity> findDeviceProfiles(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.defaultDashboardId, d.type, d.transportType) " +
"FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.DeviceProfileInfo(d.id, d.name, d.image, d.defaultDashboardId, d.type, d.transportType) " +
"FROM DeviceProfileEntity d WHERE " +
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"d.tenantId = :tenantId AND d.transportType = :transportType AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceProfileInfo> findDeviceProfileInfos(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
@Param("transportType") DeviceTransportType transportType,

30
dao/src/main/java/org/thingsboard/server/dao/sql/device/DeviceRepository.java

@ -42,7 +42,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -50,7 +50,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :profileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndProfileId(@Param("tenantId") UUID tenantId,
@Param("profileId") UUID profileId,
@Param("searchText") String searchText,
@ -62,7 +62,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -73,7 +73,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
Pageable pageable);
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -83,14 +83,14 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -99,7 +99,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND d.firmwareId = null " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndTypeAndFirmwareIdIsNull(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -108,7 +108,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND d.softwareId = null " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndTypeAndSoftwareIdIsNull(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -132,7 +132,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -144,7 +144,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"LEFT JOIN DeviceProfileEntity p on p.id = d.deviceProfileId " +
"WHERE d.tenantId = :tenantId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndDeviceProfileId(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("textSearch") String textSearch,
@ -153,7 +153,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -167,7 +167,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -181,7 +181,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.deviceProfileId = :deviceProfileId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<DeviceInfoEntity> findDeviceInfosByTenantIdAndCustomerIdAndDeviceProfileId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("deviceProfileId") UUID deviceProfileId,
@ -204,7 +204,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
@Query("SELECT d FROM DeviceEntity d, RelationEntity re WHERE d.tenantId = :tenantId " +
"AND d.id = re.toId AND re.toType = 'DEVICE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -214,7 +214,7 @@ public interface DeviceRepository extends JpaRepository<DeviceEntity, UUID> {
"AND d.id = re.toId AND re.toType = 'DEVICE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<DeviceEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

4
dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeEventRepository.java

@ -32,7 +32,7 @@ public interface EdgeEventRepository extends PagingAndSortingRepository<EdgeEven
"AND e.edgeId = :edgeId " +
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EdgeEventEntity> findEdgeEventsByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@ -47,7 +47,7 @@ public interface EdgeEventRepository extends PagingAndSortingRepository<EdgeEven
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND e.edgeEventAction <> 'TIMESERIES_UPDATED' " +
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.edgeEventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EdgeEventEntity> findEdgeEventsByTenantIdAndEdgeIdWithoutTimeseriesUpdated(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,

18
dao/src/main/java/org/thingsboard/server/dao/sql/edge/EdgeRepository.java

@ -31,7 +31,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("textSearch") String textSearch,
@ -44,7 +44,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
EdgeInfoEntity findEdgeInfoById(@Param("edgeId") UUID edgeId);
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -53,14 +53,14 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"FROM EdgeEntity d " +
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"WHERE d.tenantId = :tenantId " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -71,7 +71,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"LEFT JOIN CustomerEntity c on c.id = d.customerId " +
"WHERE d.tenantId = :tenantId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -80,7 +80,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT d FROM EdgeEntity d WHERE d.tenantId = :tenantId " +
"AND d.customerId = :customerId " +
"AND d.type = :type " +
"AND LOWER(d.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(d.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -92,7 +92,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"LEFT JOIN CustomerEntity c on c.id = a.customerId " +
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -104,7 +104,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
"WHERE a.tenantId = :tenantId " +
"AND a.customerId = :customerId " +
"AND a.type = :type " +
"AND LOWER(a.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -114,7 +114,7 @@ public interface EdgeRepository extends PagingAndSortingRepository<EdgeEntity, U
@Query("SELECT ee FROM EdgeEntity ee, RelationEntity re WHERE ee.tenantId = :tenantId " +
"AND ee.id = re.fromId AND re.fromType = 'EDGE' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.toId = :entityId AND re.toType = :entityType " +
"AND LOWER(ee.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ee.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EdgeEntity> findByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityId") UUID entityId,
@Param("entityType") String entityType,

20
dao/src/main/java/org/thingsboard/server/dao/sql/entityview/EntityViewRepository.java

@ -39,7 +39,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
EntityViewInfoEntity findEntityViewInfoById(@Param("entityViewId") UUID entityViewId);
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -48,14 +48,14 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"FROM EntityViewEntity e " +
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -66,7 +66,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") String type,
@Param("textSearch") String textSearch,
@ -74,7 +74,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -85,7 +85,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"LEFT JOIN CustomerEntity c on c.id = e.customerId " +
"WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -94,7 +94,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT e FROM EntityViewEntity e WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -107,7 +107,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"WHERE e.tenantId = :tenantId " +
"AND e.customerId = :customerId " +
"AND e.type = :type " +
"AND LOWER(e.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityViewInfoEntity> findEntityViewInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("type") String type,
@ -124,7 +124,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
@Query("SELECT ev FROM EntityViewEntity ev, RelationEntity re WHERE ev.tenantId = :tenantId " +
"AND ev.id = re.toId AND re.toType = 'ENTITY_VIEW' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -134,7 +134,7 @@ public interface EntityViewRepository extends PagingAndSortingRepository<EntityV
"AND ev.id = re.toId AND re.toType = 'ENTITY_VIEW' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND ev.type = :type " +
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(ev.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<EntityViewEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("type") String type,

2
dao/src/main/java/org/thingsboard/server/dao/sql/event/EventRepository.java

@ -55,7 +55,7 @@ public interface EventRepository extends PagingAndSortingRepository<EventEntity,
"AND e.entityType = :entityType AND e.entityId = :entityId " +
"AND (:startTime IS NULL OR e.createdTime >= :startTime) " +
"AND (:endTime IS NULL OR e.createdTime <= :endTime) " +
"AND LOWER(e.eventType) LIKE LOWER(CONCAT(:textSearch, '%'))"
"AND LOWER(e.eventType) LIKE LOWER(CONCAT('%', :textSearch, '%'))"
)
Page<EventEntity> findEventsByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
@Param("entityType") EntityType entityType,

4
dao/src/main/java/org/thingsboard/server/dao/sql/ota/OtaPackageInfoRepository.java

@ -28,7 +28,7 @@ import java.util.UUID;
public interface OtaPackageInfoRepository extends CrudRepository<OtaPackageInfoEntity, UUID> {
@Query("SELECT new OtaPackageInfoEntity(f.id, f.createdTime, f.tenantId, f.deviceProfileId, f.type, f.title, f.version, f.tag, f.url, f.fileName, f.contentType, f.checksumAlgorithm, f.checksum, f.dataSize, f.additionalInfo, CASE WHEN (f.data IS NOT NULL OR f.url IS NOT NULL) THEN true ELSE false END) FROM OtaPackageEntity f WHERE " +
"f.tenantId = :tenantId " +
"AND LOWER(f.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(f.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<OtaPackageInfoEntity> findAllByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@ -38,7 +38,7 @@ public interface OtaPackageInfoRepository extends CrudRepository<OtaPackageInfoE
"AND f.deviceProfileId = :deviceProfileId " +
"AND f.type = :type " +
"AND (f.data IS NOT NULL OR f.url IS NOT NULL) " +
"AND LOWER(f.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(f.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<OtaPackageInfoEntity> findAllByTenantIdAndTypeAndDeviceProfileIdAndHasData(@Param("tenantId") UUID tenantId,
@Param("deviceProfileId") UUID deviceProfileId,
@Param("type") OtaPackageType type,

8
dao/src/main/java/org/thingsboard/server/dao/sql/rule/RuleChainRepository.java

@ -29,14 +29,14 @@ import java.util.UUID;
public interface RuleChainRepository extends PagingAndSortingRepository<RuleChainEntity, UUID> {
@Query("SELECT rc FROM RuleChainEntity rc WHERE rc.tenantId = :tenantId " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT rc FROM RuleChainEntity rc WHERE rc.tenantId = :tenantId " +
"AND rc.type = :type " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
@Param("type") RuleChainType type,
@Param("searchText") String searchText,
@ -45,7 +45,7 @@ public interface RuleChainRepository extends PagingAndSortingRepository<RuleChai
@Query("SELECT rc FROM RuleChainEntity rc, RelationEntity re WHERE rc.tenantId = :tenantId " +
"AND rc.id = re.toId AND re.toType = 'RULE_CHAIN' AND re.relationTypeGroup = 'EDGE' " +
"AND re.relationType = 'Contains' AND re.fromId = :edgeId AND re.fromType = 'EDGE' " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
@Param("edgeId") UUID edgeId,
@Param("searchText") String searchText,
@ -54,7 +54,7 @@ public interface RuleChainRepository extends PagingAndSortingRepository<RuleChai
@Query("SELECT rc FROM RuleChainEntity rc, RelationEntity re WHERE rc.tenantId = :tenantId " +
"AND rc.id = re.toId AND re.toType = 'RULE_CHAIN' AND re.relationTypeGroup = 'EDGE_AUTO_ASSIGN_RULE_CHAIN' " +
"AND re.relationType = 'Contains' AND re.fromId = :tenantId AND re.fromType = 'TENANT' " +
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<RuleChainEntity> findAutoAssignByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantProfileRepository.java

@ -33,13 +33,13 @@ public interface TenantProfileRepository extends PagingAndSortingRepository<Tena
EntityInfo findTenantProfileInfoById(@Param("tenantProfileId") UUID tenantProfileId);
@Query("SELECT t FROM TenantProfileEntity t WHERE " +
"LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantProfileEntity> findTenantProfiles(@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT new org.thingsboard.server.common.data.EntityInfo(t.id, 'TENANT_PROFILE', t.name) " +
"FROM TenantProfileEntity t " +
"WHERE LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"WHERE LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<EntityInfo> findTenantProfileInfos(@Param("textSearch") String textSearch,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/tenant/TenantRepository.java

@ -37,7 +37,7 @@ public interface TenantRepository extends PagingAndSortingRepository<TenantEntit
TenantInfoEntity findTenantInfoById(@Param("tenantId") UUID tenantId);
@Query("SELECT t FROM TenantEntity t WHERE t.region = :region " +
"AND LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantEntity> findByRegionNextPage(@Param("region") String region,
@Param("textSearch") String textSearch,
Pageable pageable);
@ -46,7 +46,7 @@ public interface TenantRepository extends PagingAndSortingRepository<TenantEntit
"FROM TenantEntity t " +
"LEFT JOIN TenantProfileEntity p on p.id = t.tenantProfileId " +
"WHERE t.region = :region " +
"AND LOWER(t.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<TenantInfoEntity> findTenantInfoByRegionNextPage(@Param("region") String region,
@Param("textSearch") String textSearch,
Pageable pageable);

4
dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java

@ -34,7 +34,7 @@ public interface UserRepository extends PagingAndSortingRepository<UserEntity, U
@Query("SELECT u FROM UserEntity u WHERE u.tenantId = :tenantId " +
"AND u.customerId = :customerId AND u.authority = :authority " +
"AND LOWER(u.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(u.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<UserEntity> findUsersByAuthority(@Param("tenantId") UUID tenantId,
@Param("customerId") UUID customerId,
@Param("searchText") String searchText,
@ -42,7 +42,7 @@ public interface UserRepository extends PagingAndSortingRepository<UserEntity, U
Pageable pageable);
@Query("SELECT u FROM UserEntity u WHERE u.tenantId = :tenantId " +
"AND LOWER(u.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(u.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<UserEntity> findByTenantId(@Param("tenantId") UUID tenantId,
@Param("searchText") String searchText,
Pageable pageable);

6
dao/src/main/java/org/thingsboard/server/dao/sql/widget/WidgetsBundleRepository.java

@ -32,19 +32,19 @@ public interface WidgetsBundleRepository extends PagingAndSortingRepository<Widg
WidgetsBundleEntity findWidgetsBundleByTenantIdAndAlias(UUID tenantId, String alias);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId = :systemTenantId " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:searchText, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
Page<WidgetsBundleEntity> findSystemWidgetsBundles(@Param("systemTenantId") UUID systemTenantId,
@Param("searchText") String searchText,
Pageable pageable);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId = :tenantId " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<WidgetsBundleEntity> findTenantWidgetsBundlesByTenantId(@Param("tenantId") UUID tenantId,
@Param("textSearch") String textSearch,
Pageable pageable);
@Query("SELECT wb FROM WidgetsBundleEntity wb WHERE wb.tenantId IN (:tenantId, :nullTenantId) " +
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT(:textSearch, '%'))")
"AND LOWER(wb.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
Page<WidgetsBundleEntity> findAllTenantWidgetsBundlesByTenantId(@Param("tenantId") UUID tenantId,
@Param("nullTenantId") UUID nullTenantId,
@Param("textSearch") String textSearch,

Loading…
Cancel
Save