Showing
5 changed files
with
24 additions
and
56 deletions
@@ -15,12 +15,10 @@ | @@ -15,12 +15,10 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao; | 16 | package org.thingsboard.server.dao; |
17 | 17 | ||
18 | -import com.datastax.oss.driver.api.core.uuid.Uuids; | ||
19 | import org.springframework.data.domain.Page; | 18 | import org.springframework.data.domain.Page; |
20 | import org.springframework.data.domain.PageRequest; | 19 | import org.springframework.data.domain.PageRequest; |
21 | import org.springframework.data.domain.Pageable; | 20 | import org.springframework.data.domain.Pageable; |
22 | import org.springframework.data.domain.Sort; | 21 | import org.springframework.data.domain.Sort; |
23 | -import org.thingsboard.server.common.data.UUIDConverter; | ||
24 | import org.thingsboard.server.common.data.id.UUIDBased; | 22 | import org.thingsboard.server.common.data.id.UUIDBased; |
25 | import org.thingsboard.server.common.data.page.PageData; | 23 | import org.thingsboard.server.common.data.page.PageData; |
26 | import org.thingsboard.server.common.data.page.PageLink; | 24 | import org.thingsboard.server.common.data.page.PageLink; |
@@ -53,24 +51,6 @@ public abstract class DaoUtil { | @@ -53,24 +51,6 @@ public abstract class DaoUtil { | ||
53 | return PageRequest.of(pageLink.getPage(), pageLink.getPageSize(), toSort(pageLink.getSortOrder(), columnMap)); | 51 | return PageRequest.of(pageLink.getPage(), pageLink.getPageSize(), toSort(pageLink.getSortOrder(), columnMap)); |
54 | } | 52 | } |
55 | 53 | ||
56 | - public static String startTimeToId(Long startTime) { | ||
57 | - if (startTime != null) { | ||
58 | - UUID startOf = Uuids.startOf(startTime); | ||
59 | - return UUIDConverter.fromTimeUUID(startOf); | ||
60 | - } else { | ||
61 | - return null; | ||
62 | - } | ||
63 | - } | ||
64 | - | ||
65 | - public static String endTimeToId(Long endTime) { | ||
66 | - if (endTime != null) { | ||
67 | - UUID endOf = Uuids.endOf(endTime); | ||
68 | - return UUIDConverter.fromTimeUUID(endOf); | ||
69 | - } else { | ||
70 | - return null; | ||
71 | - } | ||
72 | - } | ||
73 | - | ||
74 | public static Sort toSort(SortOrder sortOrder) { | 54 | public static Sort toSort(SortOrder sortOrder) { |
75 | return toSort(sortOrder, Collections.emptyMap()); | 55 | return toSort(sortOrder, Collections.emptyMap()); |
76 | } | 56 | } |
@@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -21,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
21 | import org.springframework.data.domain.PageRequest; | 21 | import org.springframework.data.domain.PageRequest; |
22 | import org.springframework.data.repository.CrudRepository; | 22 | import org.springframework.data.repository.CrudRepository; |
23 | import org.springframework.stereotype.Component; | 23 | import org.springframework.stereotype.Component; |
24 | -import org.thingsboard.server.common.data.UUIDConverter; | ||
25 | import org.thingsboard.server.common.data.alarm.Alarm; | 24 | import org.thingsboard.server.common.data.alarm.Alarm; |
26 | import org.thingsboard.server.common.data.alarm.AlarmInfo; | 25 | import org.thingsboard.server.common.data.alarm.AlarmInfo; |
27 | import org.thingsboard.server.common.data.alarm.AlarmQuery; | 26 | import org.thingsboard.server.common.data.alarm.AlarmQuery; |
@@ -32,10 +31,8 @@ import org.thingsboard.server.common.data.id.TenantId; | @@ -32,10 +31,8 @@ import org.thingsboard.server.common.data.id.TenantId; | ||
32 | import org.thingsboard.server.common.data.page.PageData; | 31 | import org.thingsboard.server.common.data.page.PageData; |
33 | import org.thingsboard.server.common.data.query.AlarmData; | 32 | import org.thingsboard.server.common.data.query.AlarmData; |
34 | import org.thingsboard.server.common.data.query.AlarmDataPageLink; | 33 | import org.thingsboard.server.common.data.query.AlarmDataPageLink; |
35 | -import org.thingsboard.server.common.data.query.AlarmDataQuery; | ||
36 | import org.thingsboard.server.dao.DaoUtil; | 34 | import org.thingsboard.server.dao.DaoUtil; |
37 | import org.thingsboard.server.dao.alarm.AlarmDao; | 35 | import org.thingsboard.server.dao.alarm.AlarmDao; |
38 | -import org.thingsboard.server.dao.alarm.BaseAlarmService; | ||
39 | import org.thingsboard.server.dao.model.sql.AlarmEntity; | 36 | import org.thingsboard.server.dao.model.sql.AlarmEntity; |
40 | import org.thingsboard.server.dao.relation.RelationDao; | 37 | import org.thingsboard.server.dao.relation.RelationDao; |
41 | import org.thingsboard.server.dao.sql.JpaAbstractDao; | 38 | import org.thingsboard.server.dao.sql.JpaAbstractDao; |
@@ -47,9 +44,6 @@ import java.util.List; | @@ -47,9 +44,6 @@ import java.util.List; | ||
47 | import java.util.Objects; | 44 | import java.util.Objects; |
48 | import java.util.UUID; | 45 | import java.util.UUID; |
49 | 46 | ||
50 | -import static org.thingsboard.server.dao.DaoUtil.endTimeToId; | ||
51 | -import static org.thingsboard.server.dao.DaoUtil.startTimeToId; | ||
52 | - | ||
53 | /** | 47 | /** |
54 | * Created by Valerii Sosliuk on 5/19/2017. | 48 | * Created by Valerii Sosliuk on 5/19/2017. |
55 | */ | 49 | */ |
@@ -31,8 +31,8 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | @@ -31,8 +31,8 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | ||
31 | 31 | ||
32 | @Query("SELECT a FROM AuditLogEntity a WHERE " + | 32 | @Query("SELECT a FROM AuditLogEntity a WHERE " + |
33 | "a.tenantId = :tenantId " + | 33 | "a.tenantId = :tenantId " + |
34 | - "AND (:startId IS NULL OR a.id >= :startId) " + | ||
35 | - "AND (:endId IS NULL OR a.id <= :endId) " + | 34 | + "AND (:startTime IS NULL OR a.createdTime >= :startTime) " + |
35 | + "AND (:endTime IS NULL OR a.createdTime <= :endTime) " + | ||
36 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + | 36 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + |
37 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 37 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
38 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 38 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
@@ -43,16 +43,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | @@ -43,16 +43,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | ||
43 | Page<AuditLogEntity> findByTenantId( | 43 | Page<AuditLogEntity> findByTenantId( |
44 | @Param("tenantId") UUID tenantId, | 44 | @Param("tenantId") UUID tenantId, |
45 | @Param("textSearch") String textSearch, | 45 | @Param("textSearch") String textSearch, |
46 | - @Param("startId") String startId, | ||
47 | - @Param("endId") String endId, | 46 | + @Param("startTime") Long startTime, |
47 | + @Param("endTime") Long endTime, | ||
48 | @Param("actionTypes") List<ActionType> actionTypes, | 48 | @Param("actionTypes") List<ActionType> actionTypes, |
49 | Pageable pageable); | 49 | Pageable pageable); |
50 | 50 | ||
51 | @Query("SELECT a FROM AuditLogEntity a WHERE " + | 51 | @Query("SELECT a FROM AuditLogEntity a WHERE " + |
52 | "a.tenantId = :tenantId " + | 52 | "a.tenantId = :tenantId " + |
53 | "AND a.entityType = :entityType AND a.entityId = :entityId " + | 53 | "AND a.entityType = :entityType AND a.entityId = :entityId " + |
54 | - "AND (:startId IS NULL OR a.id >= :startId) " + | ||
55 | - "AND (:endId IS NULL OR a.id <= :endId) " + | 54 | + "AND (:startTime IS NULL OR a.createdTime >= :startTime) " + |
55 | + "AND (:endTime IS NULL OR a.createdTime <= :endTime) " + | ||
56 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + | 56 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + |
57 | "AND (LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 57 | "AND (LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
58 | "OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 58 | "OR LOWER(a.userName) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
@@ -63,16 +63,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | @@ -63,16 +63,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | ||
63 | @Param("entityType") EntityType entityType, | 63 | @Param("entityType") EntityType entityType, |
64 | @Param("entityId") UUID entityId, | 64 | @Param("entityId") UUID entityId, |
65 | @Param("textSearch") String textSearch, | 65 | @Param("textSearch") String textSearch, |
66 | - @Param("startId") String startId, | ||
67 | - @Param("endId") String endId, | 66 | + @Param("startTime") Long startTime, |
67 | + @Param("endTime") Long endTime, | ||
68 | @Param("actionTypes") List<ActionType> actionTypes, | 68 | @Param("actionTypes") List<ActionType> actionTypes, |
69 | Pageable pageable); | 69 | Pageable pageable); |
70 | 70 | ||
71 | @Query("SELECT a FROM AuditLogEntity a WHERE " + | 71 | @Query("SELECT a FROM AuditLogEntity a WHERE " + |
72 | "a.tenantId = :tenantId " + | 72 | "a.tenantId = :tenantId " + |
73 | "AND a.customerId = :customerId " + | 73 | "AND a.customerId = :customerId " + |
74 | - "AND (:startId IS NULL OR a.id >= :startId) " + | ||
75 | - "AND (:endId IS NULL OR a.id <= :endId) " + | 74 | + "AND (:startTime IS NULL OR a.createdTime >= :startTime) " + |
75 | + "AND (:endTime IS NULL OR a.createdTime <= :endTime) " + | ||
76 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + | 76 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + |
77 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 77 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
78 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 78 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
@@ -83,16 +83,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | @@ -83,16 +83,16 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | ||
83 | Page<AuditLogEntity> findAuditLogsByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId, | 83 | Page<AuditLogEntity> findAuditLogsByTenantIdAndCustomerId(@Param("tenantId") UUID tenantId, |
84 | @Param("customerId") UUID customerId, | 84 | @Param("customerId") UUID customerId, |
85 | @Param("textSearch") String textSearch, | 85 | @Param("textSearch") String textSearch, |
86 | - @Param("startId") String startId, | ||
87 | - @Param("endId") String endId, | 86 | + @Param("startTime") Long startTime, |
87 | + @Param("endTime") Long endTime, | ||
88 | @Param("actionTypes") List<ActionType> actionTypes, | 88 | @Param("actionTypes") List<ActionType> actionTypes, |
89 | Pageable pageable); | 89 | Pageable pageable); |
90 | 90 | ||
91 | @Query("SELECT a FROM AuditLogEntity a WHERE " + | 91 | @Query("SELECT a FROM AuditLogEntity a WHERE " + |
92 | "a.tenantId = :tenantId " + | 92 | "a.tenantId = :tenantId " + |
93 | "AND a.userId = :userId " + | 93 | "AND a.userId = :userId " + |
94 | - "AND (:startId IS NULL OR a.id >= :startId) " + | ||
95 | - "AND (:endId IS NULL OR a.id <= :endId) " + | 94 | + "AND (:startTime IS NULL OR a.createdTime >= :startTime) " + |
95 | + "AND (:endTime IS NULL OR a.createdTime <= :endTime) " + | ||
96 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + | 96 | "AND (:actionTypes IS NULL OR a.actionType in :actionTypes) " + |
97 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 97 | "AND (LOWER(a.entityType) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
98 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + | 98 | "OR LOWER(a.entityName) LIKE LOWER(CONCAT(:textSearch, '%'))" + |
@@ -102,8 +102,8 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | @@ -102,8 +102,8 @@ public interface AuditLogRepository extends PagingAndSortingRepository<AuditLogE | ||
102 | Page<AuditLogEntity> findAuditLogsByTenantIdAndUserId(@Param("tenantId") UUID tenantId, | 102 | Page<AuditLogEntity> findAuditLogsByTenantIdAndUserId(@Param("tenantId") UUID tenantId, |
103 | @Param("userId") UUID userId, | 103 | @Param("userId") UUID userId, |
104 | @Param("textSearch") String textSearch, | 104 | @Param("textSearch") String textSearch, |
105 | - @Param("startId") String startId, | ||
106 | - @Param("endId") String endId, | 105 | + @Param("startTime") Long startTime, |
106 | + @Param("endTime") Long endTime, | ||
107 | @Param("actionTypes") List<ActionType> actionTypes, | 107 | @Param("actionTypes") List<ActionType> actionTypes, |
108 | Pageable pageable); | 108 | Pageable pageable); |
109 | 109 |
@@ -36,9 +36,6 @@ import java.util.List; | @@ -36,9 +36,6 @@ import java.util.List; | ||
36 | import java.util.Objects; | 36 | import java.util.Objects; |
37 | import java.util.UUID; | 37 | import java.util.UUID; |
38 | 38 | ||
39 | -import static org.thingsboard.server.dao.DaoUtil.endTimeToId; | ||
40 | -import static org.thingsboard.server.dao.DaoUtil.startTimeToId; | ||
41 | - | ||
42 | @Component | 39 | @Component |
43 | @SqlDao | 40 | @SqlDao |
44 | public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> implements AuditLogDao { | 41 | public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> implements AuditLogDao { |
@@ -73,8 +70,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | @@ -73,8 +70,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | ||
73 | entityId.getEntityType(), | 70 | entityId.getEntityType(), |
74 | entityId.getId(), | 71 | entityId.getId(), |
75 | Objects.toString(pageLink.getTextSearch(), ""), | 72 | Objects.toString(pageLink.getTextSearch(), ""), |
76 | - startTimeToId(pageLink.getStartTime()), | ||
77 | - endTimeToId(pageLink.getEndTime()), | 73 | + pageLink.getStartTime(), |
74 | + pageLink.getEndTime(), | ||
78 | actionTypes, | 75 | actionTypes, |
79 | DaoUtil.toPageable(pageLink))); | 76 | DaoUtil.toPageable(pageLink))); |
80 | } | 77 | } |
@@ -87,8 +84,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | @@ -87,8 +84,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | ||
87 | tenantId, | 84 | tenantId, |
88 | customerId.getId(), | 85 | customerId.getId(), |
89 | Objects.toString(pageLink.getTextSearch(), ""), | 86 | Objects.toString(pageLink.getTextSearch(), ""), |
90 | - startTimeToId(pageLink.getStartTime()), | ||
91 | - endTimeToId(pageLink.getEndTime()), | 87 | + pageLink.getStartTime(), |
88 | + pageLink.getEndTime(), | ||
92 | actionTypes, | 89 | actionTypes, |
93 | DaoUtil.toPageable(pageLink))); | 90 | DaoUtil.toPageable(pageLink))); |
94 | } | 91 | } |
@@ -101,8 +98,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | @@ -101,8 +98,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | ||
101 | tenantId, | 98 | tenantId, |
102 | userId.getId(), | 99 | userId.getId(), |
103 | Objects.toString(pageLink.getTextSearch(), ""), | 100 | Objects.toString(pageLink.getTextSearch(), ""), |
104 | - startTimeToId(pageLink.getStartTime()), | ||
105 | - endTimeToId(pageLink.getEndTime()), | 101 | + pageLink.getStartTime(), |
102 | + pageLink.getEndTime(), | ||
106 | actionTypes, | 103 | actionTypes, |
107 | DaoUtil.toPageable(pageLink))); | 104 | DaoUtil.toPageable(pageLink))); |
108 | } | 105 | } |
@@ -113,8 +110,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | @@ -113,8 +110,8 @@ public class JpaAuditLogDao extends JpaAbstractDao<AuditLogEntity, AuditLog> imp | ||
113 | auditLogRepository.findByTenantId( | 110 | auditLogRepository.findByTenantId( |
114 | tenantId, | 111 | tenantId, |
115 | Objects.toString(pageLink.getTextSearch(), ""), | 112 | Objects.toString(pageLink.getTextSearch(), ""), |
116 | - startTimeToId(pageLink.getStartTime()), | ||
117 | - endTimeToId(pageLink.getEndTime()), | 113 | + pageLink.getStartTime(), |
114 | + pageLink.getEndTime(), | ||
118 | actionTypes, | 115 | actionTypes, |
119 | DaoUtil.toPageable(pageLink))); | 116 | DaoUtil.toPageable(pageLink))); |
120 | } | 117 | } |
@@ -25,7 +25,6 @@ import org.springframework.data.jpa.domain.Specification; | @@ -25,7 +25,6 @@ import org.springframework.data.jpa.domain.Specification; | ||
25 | import org.springframework.data.repository.CrudRepository; | 25 | import org.springframework.data.repository.CrudRepository; |
26 | import org.springframework.stereotype.Component; | 26 | import org.springframework.stereotype.Component; |
27 | import org.thingsboard.server.common.data.Event; | 27 | import org.thingsboard.server.common.data.Event; |
28 | -import org.thingsboard.server.common.data.UUIDConverter; | ||
29 | import org.thingsboard.server.common.data.id.EntityId; | 28 | import org.thingsboard.server.common.data.id.EntityId; |
30 | import org.thingsboard.server.common.data.id.EventId; | 29 | import org.thingsboard.server.common.data.id.EventId; |
31 | import org.thingsboard.server.common.data.id.TenantId; | 30 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -44,8 +43,6 @@ import java.util.Objects; | @@ -44,8 +43,6 @@ import java.util.Objects; | ||
44 | import java.util.Optional; | 43 | import java.util.Optional; |
45 | import java.util.UUID; | 44 | import java.util.UUID; |
46 | 45 | ||
47 | -import static org.thingsboard.server.dao.DaoUtil.endTimeToId; | ||
48 | -import static org.thingsboard.server.dao.DaoUtil.startTimeToId; | ||
49 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; | 46 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
50 | 47 | ||
51 | /** | 48 | /** |