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