refactoring Asset and Customer
This commit is contained in:
		
							parent
							
								
									35bbff3cac
								
							
						
					
					
						commit
						2eb1aa5b30
					
				@ -28,7 +28,6 @@ import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
 | 
			
		||||
import org.thingsboard.server.common.data.ota.OtaPackageType;
 | 
			
		||||
import org.thingsboard.server.dao.model.BaseSqlEntity;
 | 
			
		||||
import org.thingsboard.server.dao.model.ModelConstants;
 | 
			
		||||
import org.thingsboard.server.dao.model.SearchTextEntity;
 | 
			
		||||
import org.thingsboard.server.dao.util.mapping.JsonStringType;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
@ -61,7 +60,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPER
 | 
			
		||||
@Entity
 | 
			
		||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
 | 
			
		||||
@Table(name = OTA_PACKAGE_TABLE_NAME)
 | 
			
		||||
public class OtaPackageEntity extends BaseSqlEntity<OtaPackage> implements SearchTextEntity<OtaPackage> {
 | 
			
		||||
public class OtaPackageEntity extends BaseSqlEntity<OtaPackage> {
 | 
			
		||||
 | 
			
		||||
    @Column(name = OTA_PACKAGE_TENANT_ID_COLUMN)
 | 
			
		||||
    private UUID tenantId;
 | 
			
		||||
@ -137,16 +136,6 @@ public class OtaPackageEntity extends BaseSqlEntity<OtaPackage> implements Searc
 | 
			
		||||
        this.additionalInfo = otaPackage.getAdditionalInfo();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSearchTextSource() {
 | 
			
		||||
        return title;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setSearchText(String searchText) {
 | 
			
		||||
        this.searchText = searchText;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OtaPackage toData() {
 | 
			
		||||
        OtaPackage otaPackage = new OtaPackage(new OtaPackageId(id));
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,6 @@ import org.thingsboard.server.common.data.ota.ChecksumAlgorithm;
 | 
			
		||||
import org.thingsboard.server.common.data.ota.OtaPackageType;
 | 
			
		||||
import org.thingsboard.server.dao.model.BaseSqlEntity;
 | 
			
		||||
import org.thingsboard.server.dao.model.ModelConstants;
 | 
			
		||||
import org.thingsboard.server.dao.model.SearchTextEntity;
 | 
			
		||||
import org.thingsboard.server.dao.util.mapping.JsonStringType;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
@ -60,7 +59,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPER
 | 
			
		||||
@Entity
 | 
			
		||||
@TypeDef(name = "json", typeClass = JsonStringType.class)
 | 
			
		||||
@Table(name = OTA_PACKAGE_TABLE_NAME)
 | 
			
		||||
public class OtaPackageInfoEntity extends BaseSqlEntity<OtaPackageInfo> implements SearchTextEntity<OtaPackageInfo> {
 | 
			
		||||
public class OtaPackageInfoEntity extends BaseSqlEntity<OtaPackageInfo> {
 | 
			
		||||
 | 
			
		||||
    @Column(name = OTA_PACKAGE_TENANT_ID_COLUMN)
 | 
			
		||||
    private UUID tenantId;
 | 
			
		||||
@ -155,16 +154,6 @@ public class OtaPackageInfoEntity extends BaseSqlEntity<OtaPackageInfo> implemen
 | 
			
		||||
        this.additionalInfo = JacksonUtil.convertValue(additionalInfo, JsonNode.class);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getSearchTextSource() {
 | 
			
		||||
        return title;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setSearchText(String searchText) {
 | 
			
		||||
        this.searchText = searchText;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public OtaPackageInfo toData() {
 | 
			
		||||
        OtaPackageInfo otaPackageInfo = new OtaPackageInfo(new OtaPackageId(id));
 | 
			
		||||
 | 
			
		||||
@ -41,7 +41,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
    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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                     @Param("textSearch") String textSearch,
 | 
			
		||||
                                     Pageable pageable);
 | 
			
		||||
@ -51,17 +51,17 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "LEFT JOIN CustomerEntity c on c.id = a.customerId " +
 | 
			
		||||
            "LEFT JOIN AssetProfileEntity p on p.id = a.assetProfileId " +
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND (LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "AND (LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(a.label) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(p.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(c.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')))")
 | 
			
		||||
            "OR LOWER(p.name) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(c.title) 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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                  @Param("customerId") UUID customerId,
 | 
			
		||||
                                                  @Param("textSearch") String textSearch,
 | 
			
		||||
@ -69,7 +69,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
 | 
			
		||||
    @Query("SELECT a FROM AssetEntity a WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.assetProfileId = :profileId " +
 | 
			
		||||
            "AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
            "AND LOWER(a.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndProfileId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                 @Param("profileId") UUID profileId,
 | 
			
		||||
                                                 @Param("searchText") String searchText,
 | 
			
		||||
@ -81,7 +81,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "LEFT JOIN AssetProfileEntity p on p.id = a.assetProfileId " +
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.customerId = :customerId " +
 | 
			
		||||
            "AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
            "AND LOWER(a.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                @Param("customerId") UUID customerId,
 | 
			
		||||
                                                                @Param("searchText") String searchText,
 | 
			
		||||
@ -95,7 +95,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                            @Param("type") String type,
 | 
			
		||||
                                            @Param("textSearch") String textSearch,
 | 
			
		||||
@ -107,9 +107,9 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "LEFT JOIN AssetProfileEntity p on p.id = a.assetProfileId " +
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.type = :type " +
 | 
			
		||||
            "AND (LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "AND (LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(a.label) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(c.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')))")
 | 
			
		||||
            "OR LOWER(c.title) LIKE LOWER(CONCAT('%', :textSearch, '%')))")
 | 
			
		||||
    Page<AssetInfoEntity> findAssetInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                          @Param("type") String type,
 | 
			
		||||
                                                          @Param("textSearch") String textSearch,
 | 
			
		||||
@ -121,9 +121,9 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "LEFT JOIN AssetProfileEntity p on p.id = a.assetProfileId " +
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.assetProfileId = :assetProfileId " +
 | 
			
		||||
            "AND (LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "AND (LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(a.label) LIKE LOWER(CONCAT('%', :textSearch, '%')) " +
 | 
			
		||||
            "OR LOWER(c.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%')))")
 | 
			
		||||
            "OR LOWER(c.title) LIKE LOWER(CONCAT('%', :textSearch, '%')))")
 | 
			
		||||
    Page<AssetInfoEntity> findAssetInfosByTenantIdAndAssetProfileId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                    @Param("assetProfileId") UUID assetProfileId,
 | 
			
		||||
                                                                    @Param("textSearch") String textSearch,
 | 
			
		||||
@ -132,7 +132,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                         @Param("customerId") UUID customerId,
 | 
			
		||||
                                                         @Param("type") String type,
 | 
			
		||||
@ -146,7 +146,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.customerId = :customerId " +
 | 
			
		||||
            "AND a.type = :type " +
 | 
			
		||||
            "AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
            "AND LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                       @Param("customerId") UUID customerId,
 | 
			
		||||
                                                                       @Param("type") String type,
 | 
			
		||||
@ -160,7 +160,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.customerId = :customerId " +
 | 
			
		||||
            "AND a.assetProfileId = :assetProfileId " +
 | 
			
		||||
            "AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
            "AND LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<AssetInfoEntity> findAssetInfosByTenantIdAndCustomerIdAndAssetProfileId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                                 @Param("customerId") UUID customerId,
 | 
			
		||||
                                                                                 @Param("assetProfileId") UUID assetProfileId,
 | 
			
		||||
@ -175,7 +175,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                              @Param("edgeId") UUID edgeId,
 | 
			
		||||
                                              @Param("searchText") String searchText,
 | 
			
		||||
@ -185,7 +185,7 @@ public interface AssetRepository extends JpaRepository<AssetEntity, UUID>, Expor
 | 
			
		||||
            "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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<AssetEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                     @Param("edgeId") UUID edgeId,
 | 
			
		||||
                                                     @Param("type") String type,
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeEntity> findByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                 @Param("customerId") UUID customerId,
 | 
			
		||||
                                                 @Param("textSearch") String textSearch,
 | 
			
		||||
@ -43,7 +43,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
    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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeEntity> findByTenantId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                    @Param("textSearch") String textSearch,
 | 
			
		||||
                                    Pageable pageable);
 | 
			
		||||
@ -52,14 +52,14 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
            "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.name) 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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                           @Param("type") String type,
 | 
			
		||||
                                           @Param("textSearch") String textSearch,
 | 
			
		||||
@ -70,7 +70,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
            "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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                        @Param("type") String type,
 | 
			
		||||
                                                        @Param("textSearch") String textSearch,
 | 
			
		||||
@ -79,7 +79,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeEntity> findByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                        @Param("customerId") UUID customerId,
 | 
			
		||||
                                                        @Param("type") String type,
 | 
			
		||||
@ -91,7 +91,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
            "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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                @Param("customerId") UUID customerId,
 | 
			
		||||
                                                                @Param("searchText") String searchText,
 | 
			
		||||
@ -103,7 +103,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
            "WHERE a.tenantId = :tenantId " +
 | 
			
		||||
            "AND a.customerId = :customerId " +
 | 
			
		||||
            "AND a.type = :type " +
 | 
			
		||||
            "AND LOWER(a.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
            "AND LOWER(a.name) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<EdgeInfoEntity> findEdgeInfosByTenantIdAndCustomerIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                       @Param("customerId") UUID customerId,
 | 
			
		||||
                                                                       @Param("type") String type,
 | 
			
		||||
@ -113,7 +113,7 @@ public interface EdgeRepository extends JpaRepository<EdgeEntity, UUID> {
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<EdgeEntity> findByTenantIdAndEntityId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                               @Param("entityId") UUID entityId,
 | 
			
		||||
                                               @Param("entityType") String entityType,
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,7 @@ public interface EntityViewRepository extends JpaRepository<EntityViewEntity, UU
 | 
			
		||||
    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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
            "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.name) 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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
            "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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
 | 
			
		||||
    @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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
            "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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
    @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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
            "WHERE e.tenantId = :tenantId " +
 | 
			
		||||
            "AND e.customerId = :customerId " +
 | 
			
		||||
            "AND e.type = :type " +
 | 
			
		||||
            "AND LOWER(e.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
            "AND LOWER(e.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
    @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.name) 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 JpaRepository<EntityViewEntity, UU
 | 
			
		||||
            "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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<EntityViewEntity> findByTenantIdAndEdgeIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                   @Param("edgeId") UUID edgeId,
 | 
			
		||||
                                                   @Param("type") String type,
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,7 @@ import org.thingsboard.server.common.data.page.PageLink;
 | 
			
		||||
import org.thingsboard.server.dao.DaoUtil;
 | 
			
		||||
import org.thingsboard.server.dao.model.sql.OtaPackageInfoEntity;
 | 
			
		||||
import org.thingsboard.server.dao.ota.OtaPackageInfoDao;
 | 
			
		||||
import org.thingsboard.server.dao.sql.JpaAbstractSearchTextDao;
 | 
			
		||||
import org.thingsboard.server.dao.sql.JpaAbstractDao;
 | 
			
		||||
import org.thingsboard.server.dao.util.SqlDao;
 | 
			
		||||
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
@ -38,7 +38,7 @@ import java.util.UUID;
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Component
 | 
			
		||||
@SqlDao
 | 
			
		||||
public class JpaOtaPackageInfoDao extends JpaAbstractSearchTextDao<OtaPackageInfoEntity, OtaPackageInfo> implements OtaPackageInfoDao {
 | 
			
		||||
public class JpaOtaPackageInfoDao extends JpaAbstractDao<OtaPackageInfoEntity, OtaPackageInfo> implements OtaPackageInfoDao {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private OtaPackageInfoRepository otaPackageInfoRepository;
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,7 @@ import java.util.UUID;
 | 
			
		||||
public interface OtaPackageInfoRepository extends JpaRepository<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.title) 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 JpaRepository<OtaPackageInfoEn
 | 
			
		||||
            "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.title) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<OtaPackageInfoEntity> findAllByTenantIdAndTypeAndDeviceProfileIdAndHasData(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                                    @Param("deviceProfileId") UUID deviceProfileId,
 | 
			
		||||
                                                                                    @Param("type") OtaPackageType type,
 | 
			
		||||
 | 
			
		||||
@ -30,14 +30,14 @@ import java.util.UUID;
 | 
			
		||||
public interface RuleChainRepository extends JpaRepository<RuleChainEntity, UUID>, ExportableEntityRepository<RuleChainEntity> {
 | 
			
		||||
 | 
			
		||||
    @Query("SELECT rc FROM RuleChainEntity rc WHERE rc.tenantId = :tenantId " +
 | 
			
		||||
            "AND LOWER(rc.searchText) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
            "AND LOWER(rc.name) 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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<RuleChainEntity> findByTenantIdAndType(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                @Param("type") RuleChainType type,
 | 
			
		||||
                                                @Param("searchText") String searchText,
 | 
			
		||||
@ -46,7 +46,7 @@ public interface RuleChainRepository extends JpaRepository<RuleChainEntity, UUID
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<RuleChainEntity> findByTenantIdAndEdgeId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                  @Param("edgeId") UUID edgeId,
 | 
			
		||||
                                                  @Param("searchText") String searchText,
 | 
			
		||||
@ -55,7 +55,7 @@ public interface RuleChainRepository extends JpaRepository<RuleChainEntity, UUID
 | 
			
		||||
    @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.name) LIKE LOWER(CONCAT('%', :searchText, '%'))")
 | 
			
		||||
    Page<RuleChainEntity> findAutoAssignByTenantId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                   @Param("searchText") String searchText,
 | 
			
		||||
                                                   Pageable pageable);
 | 
			
		||||
 | 
			
		||||
@ -37,14 +37,14 @@ public interface TenantRepository extends JpaRepository<TenantEntity, UUID> {
 | 
			
		||||
            "WHERE t.id = :tenantId")
 | 
			
		||||
    TenantInfoEntity findTenantInfoById(@Param("tenantId") UUID tenantId);
 | 
			
		||||
 | 
			
		||||
    @Query("SELECT t FROM TenantEntity t WHERE LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    @Query("SELECT t FROM TenantEntity t WHERE LOWER(t.title) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<TenantEntity> findTenantsNextPage(@Param("textSearch") String textSearch,
 | 
			
		||||
                                           Pageable pageable);
 | 
			
		||||
 | 
			
		||||
    @Query("SELECT new org.thingsboard.server.dao.model.sql.TenantInfoEntity(t, p.name) " +
 | 
			
		||||
            "FROM TenantEntity t " +
 | 
			
		||||
            "LEFT JOIN TenantProfileEntity p on p.id = t.tenantProfileId " +
 | 
			
		||||
            "WHERE LOWER(t.searchText) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
            "WHERE LOWER(t.title) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<TenantInfoEntity> findTenantInfosNextPage(@Param("textSearch") String textSearch,
 | 
			
		||||
                                                          Pageable pageable);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,19 +33,19 @@ public interface WidgetsBundleRepository extends JpaRepository<WidgetsBundleEnti
 | 
			
		||||
    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.title) 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.title) 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.title) LIKE LOWER(CONCAT('%', :textSearch, '%'))")
 | 
			
		||||
    Page<WidgetsBundleEntity> findAllTenantWidgetsBundlesByTenantId(@Param("tenantId") UUID tenantId,
 | 
			
		||||
                                                                    @Param("nullTenantId") UUID nullTenantId,
 | 
			
		||||
                                                                    @Param("textSearch") String textSearch,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user