Showing
11 changed files
with
71 additions
and
65 deletions
@@ -15,14 +15,11 @@ | @@ -15,14 +15,11 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.common.data.rule; | 16 | package org.thingsboard.server.common.data.rule; |
17 | 17 | ||
18 | +import com.fasterxml.jackson.databind.JsonNode; | ||
18 | import lombok.Data; | 19 | import lombok.Data; |
19 | -import lombok.ToString; | ||
20 | import org.thingsboard.server.common.data.SearchTextBased; | 20 | import org.thingsboard.server.common.data.SearchTextBased; |
21 | -import org.thingsboard.server.common.data.id.CustomerId; | ||
22 | import org.thingsboard.server.common.data.id.RuleId; | 21 | import org.thingsboard.server.common.data.id.RuleId; |
23 | import org.thingsboard.server.common.data.id.TenantId; | 22 | import org.thingsboard.server.common.data.id.TenantId; |
24 | - | ||
25 | -import com.fasterxml.jackson.databind.JsonNode; | ||
26 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; | 23 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; |
27 | 24 | ||
28 | @Data | 25 | @Data |
@@ -27,8 +27,10 @@ import com.google.common.base.Function; | @@ -27,8 +27,10 @@ import com.google.common.base.Function; | ||
27 | import com.google.common.util.concurrent.Futures; | 27 | import com.google.common.util.concurrent.Futures; |
28 | import com.google.common.util.concurrent.ListenableFuture; | 28 | import com.google.common.util.concurrent.ListenableFuture; |
29 | import lombok.extern.slf4j.Slf4j; | 29 | import lombok.extern.slf4j.Slf4j; |
30 | +import org.thingsboard.server.common.data.SearchTextBased; | ||
30 | import org.thingsboard.server.dao.model.BaseEntity; | 31 | import org.thingsboard.server.dao.model.BaseEntity; |
31 | import org.thingsboard.server.dao.model.ModelConstants; | 32 | import org.thingsboard.server.dao.model.ModelConstants; |
33 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
32 | import org.thingsboard.server.dao.model.wrapper.EntityResultSet; | 34 | import org.thingsboard.server.dao.model.wrapper.EntityResultSet; |
33 | 35 | ||
34 | import javax.annotation.Nullable; | 36 | import javax.annotation.Nullable; |
@@ -46,6 +48,10 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte | @@ -46,6 +48,10 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte | ||
46 | 48 | ||
47 | protected abstract String getColumnFamilyName(); | 49 | protected abstract String getColumnFamilyName(); |
48 | 50 | ||
51 | + protected boolean isSearchTextDao() { | ||
52 | + return false; | ||
53 | + } | ||
54 | + | ||
49 | protected Mapper<E> getMapper() { | 55 | protected Mapper<E> getMapper() { |
50 | return cluster.getMapper(getColumnFamilyClass()); | 56 | return cluster.getMapper(getColumnFamilyClass()); |
51 | } | 57 | } |
@@ -144,6 +150,9 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte | @@ -144,6 +150,9 @@ public abstract class CassandraAbstractModelDao<E extends BaseEntity<D>, D> exte | ||
144 | log.error("Can't create entity for domain object {}", domain, e); | 150 | log.error("Can't create entity for domain object {}", domain, e); |
145 | throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e); | 151 | throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e); |
146 | } | 152 | } |
153 | + if (isSearchTextDao()) { | ||
154 | + ((SearchTextEntity) entity).setSearchText(((SearchTextEntity) entity).getSearchTextSource().toLowerCase()); | ||
155 | + } | ||
147 | log.debug("Saving entity {}", entity); | 156 | log.debug("Saving entity {}", entity); |
148 | entity = saveWithResult(entity).getEntity(); | 157 | entity = saveWithResult(entity).getEntity(); |
149 | return DaoUtil.getData(entity); | 158 | return DaoUtil.getData(entity); |
@@ -33,11 +33,9 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | @@ -33,11 +33,9 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | ||
33 | @Slf4j | 33 | @Slf4j |
34 | public abstract class CassandraAbstractSearchTextDao<E extends SearchTextEntity<D>, D> extends CassandraAbstractModelDao<E, D> { | 34 | public abstract class CassandraAbstractSearchTextDao<E extends SearchTextEntity<D>, D> extends CassandraAbstractModelDao<E, D> { |
35 | 35 | ||
36 | - public D save(D domain) { | ||
37 | - | ||
38 | - entity.setSearchText(entity.getSearchTextSource().toLowerCase()); | ||
39 | - | ||
40 | - return super.save(entity); | 36 | + @Override |
37 | + protected boolean isSearchTextDao() { | ||
38 | + return true; | ||
41 | } | 39 | } |
42 | 40 | ||
43 | protected List<E> findPageWithTextSearch(String searchView, List<Clause> clauses, TextPageLink pageLink) { | 41 | protected List<E> findPageWithTextSearch(String searchView, List<Clause> clauses, TextPageLink pageLink) { |
dao/src/main/java/org/thingsboard/server/dao/CassandraAbstractSearchTimeDao.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/AbstractSearchTimeDao.java
@@ -32,7 +32,7 @@ import java.util.UUID; | @@ -32,7 +32,7 @@ import java.util.UUID; | ||
32 | 32 | ||
33 | import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | 33 | import static com.datastax.driver.core.querybuilder.QueryBuilder.select; |
34 | 34 | ||
35 | -public abstract class AbstractSearchTimeDao<E extends BaseEntity<D>, D> extends CassandraAbstractModelDao<E, D> { | 35 | +public abstract class CassandraAbstractSearchTimeDao<E extends BaseEntity<D>, D> extends CassandraAbstractModelDao<E, D> { |
36 | 36 | ||
37 | 37 | ||
38 | protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, TimePageLink pageLink) { | 38 | protected List<E> findPageWithTimeSearch(String searchView, List<Clause> clauses, TimePageLink pageLink) { |
dao/src/main/java/org/thingsboard/server/dao/component/CassandraBaseComponentDescriptorDao.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/component/BaseComponentDescriptorDao.java
@@ -45,7 +45,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | @@ -45,7 +45,7 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | ||
45 | */ | 45 | */ |
46 | @Component | 46 | @Component |
47 | @Slf4j | 47 | @Slf4j |
48 | -public class BaseComponentDescriptorDao extends CassandraAbstractSearchTextDao<ComponentDescriptorEntity, ComponentDescriptor> implements ComponentDescriptorDao { | 48 | +public class CassandraBaseComponentDescriptorDao extends CassandraAbstractSearchTextDao<ComponentDescriptorEntity, ComponentDescriptor> implements ComponentDescriptorDao { |
49 | 49 | ||
50 | @Override | 50 | @Override |
51 | protected Class<ComponentDescriptorEntity> getColumnFamilyClass() { | 51 | protected Class<ComponentDescriptorEntity> getColumnFamilyClass() { |
@@ -23,7 +23,9 @@ import org.apache.commons.lang3.RandomStringUtils; | @@ -23,7 +23,9 @@ import org.apache.commons.lang3.RandomStringUtils; | ||
23 | import org.springframework.beans.factory.annotation.Autowired; | 23 | import org.springframework.beans.factory.annotation.Autowired; |
24 | import org.springframework.stereotype.Service; | 24 | import org.springframework.stereotype.Service; |
25 | import org.springframework.util.StringUtils; | 25 | import org.springframework.util.StringUtils; |
26 | +import org.thingsboard.server.common.data.Customer; | ||
26 | import org.thingsboard.server.common.data.Device; | 27 | import org.thingsboard.server.common.data.Device; |
28 | +import org.thingsboard.server.common.data.Tenant; | ||
27 | import org.thingsboard.server.common.data.id.CustomerId; | 29 | import org.thingsboard.server.common.data.id.CustomerId; |
28 | import org.thingsboard.server.common.data.id.DeviceId; | 30 | import org.thingsboard.server.common.data.id.DeviceId; |
29 | import org.thingsboard.server.common.data.id.TenantId; | 31 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -33,9 +35,7 @@ import org.thingsboard.server.common.data.security.DeviceCredentials; | @@ -33,9 +35,7 @@ import org.thingsboard.server.common.data.security.DeviceCredentials; | ||
33 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; | 35 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
34 | import org.thingsboard.server.dao.customer.CustomerDao; | 36 | import org.thingsboard.server.dao.customer.CustomerDao; |
35 | import org.thingsboard.server.dao.exception.DataValidationException; | 37 | import org.thingsboard.server.dao.exception.DataValidationException; |
36 | -import org.thingsboard.server.dao.model.CustomerEntity; | ||
37 | import org.thingsboard.server.dao.model.DeviceEntity; | 38 | import org.thingsboard.server.dao.model.DeviceEntity; |
38 | -import org.thingsboard.server.dao.model.TenantEntity; | ||
39 | import org.thingsboard.server.dao.service.DataValidator; | 39 | import org.thingsboard.server.dao.service.DataValidator; |
40 | import org.thingsboard.server.dao.service.PaginatedRemover; | 40 | import org.thingsboard.server.dao.service.PaginatedRemover; |
41 | import org.thingsboard.server.dao.tenant.TenantDao; | 41 | import org.thingsboard.server.dao.tenant.TenantDao; |
@@ -43,9 +43,13 @@ import org.thingsboard.server.dao.tenant.TenantDao; | @@ -43,9 +43,13 @@ import org.thingsboard.server.dao.tenant.TenantDao; | ||
43 | import java.util.List; | 43 | import java.util.List; |
44 | import java.util.Optional; | 44 | import java.util.Optional; |
45 | 45 | ||
46 | -import static org.thingsboard.server.dao.DaoUtil.*; | 46 | +import static org.thingsboard.server.dao.DaoUtil.convertDataList; |
47 | +import static org.thingsboard.server.dao.DaoUtil.getData; | ||
48 | +import static org.thingsboard.server.dao.DaoUtil.toUUIDs; | ||
47 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; | 49 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
48 | -import static org.thingsboard.server.dao.service.Validator.*; | 50 | +import static org.thingsboard.server.dao.service.Validator.validateId; |
51 | +import static org.thingsboard.server.dao.service.Validator.validateIds; | ||
52 | +import static org.thingsboard.server.dao.service.Validator.validatePageLink; | ||
49 | 53 | ||
50 | @Service | 54 | @Service |
51 | @Slf4j | 55 | @Slf4j |
@@ -74,17 +78,16 @@ public class DeviceServiceImpl implements DeviceService { | @@ -74,17 +78,16 @@ public class DeviceServiceImpl implements DeviceService { | ||
74 | public ListenableFuture<Device> findDeviceByIdAsync(DeviceId deviceId) { | 78 | public ListenableFuture<Device> findDeviceByIdAsync(DeviceId deviceId) { |
75 | log.trace("Executing findDeviceById [{}]", deviceId); | 79 | log.trace("Executing findDeviceById [{}]", deviceId); |
76 | validateId(deviceId, "Incorrect deviceId " + deviceId); | 80 | validateId(deviceId, "Incorrect deviceId " + deviceId); |
77 | - ListenableFuture<Device> deviceEntity = deviceDao.findByIdAsync(deviceId.getId()); | ||
78 | - return Futures.transform(deviceEntity, (Function<? super DeviceEntity, ? extends Device>) input -> getData(input)); | 81 | + return deviceDao.findByIdAsync(deviceId.getId()); |
79 | } | 82 | } |
80 | 83 | ||
81 | @Override | 84 | @Override |
82 | public Optional<Device> findDeviceByTenantIdAndName(TenantId tenantId, String name) { | 85 | public Optional<Device> findDeviceByTenantIdAndName(TenantId tenantId, String name) { |
83 | log.trace("Executing findDeviceByTenantIdAndName [{}][{}]", tenantId, name); | 86 | log.trace("Executing findDeviceByTenantIdAndName [{}][{}]", tenantId, name); |
84 | validateId(tenantId, "Incorrect tenantId " + tenantId); | 87 | validateId(tenantId, "Incorrect tenantId " + tenantId); |
85 | - Optional<Device> deviceEntityOpt = deviceDao.findDevicesByTenantIdAndName(tenantId.getId(), name); | ||
86 | - if (deviceEntityOpt.isPresent()) { | ||
87 | - return Optional.of(deviceEntityOpt.get()); | 88 | + Optional<Device> deviceOpt = deviceDao.findDevicesByTenantIdAndName(tenantId.getId(), name); |
89 | + if (deviceOpt.isPresent()) { | ||
90 | + return Optional.of(deviceOpt.get()); | ||
88 | } else { | 91 | } else { |
89 | return Optional.empty(); | 92 | return Optional.empty(); |
90 | } | 93 | } |
@@ -136,7 +139,7 @@ public class DeviceServiceImpl implements DeviceService { | @@ -136,7 +139,7 @@ public class DeviceServiceImpl implements DeviceService { | ||
136 | validateId(tenantId, "Incorrect tenantId " + tenantId); | 139 | validateId(tenantId, "Incorrect tenantId " + tenantId); |
137 | validatePageLink(pageLink, "Incorrect page link " + pageLink); | 140 | validatePageLink(pageLink, "Incorrect page link " + pageLink); |
138 | List<Device> devices = deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink); | 141 | List<Device> devices = deviceDao.findDevicesByTenantId(tenantId.getId(), pageLink); |
139 | - return new TextPageData<Device>(devices, pageLink); | 142 | + return new TextPageData<>(devices, pageLink); |
140 | } | 143 | } |
141 | 144 | ||
142 | @Override | 145 | @Override |
@@ -144,8 +147,7 @@ public class DeviceServiceImpl implements DeviceService { | @@ -144,8 +147,7 @@ public class DeviceServiceImpl implements DeviceService { | ||
144 | log.trace("Executing findDevicesByTenantIdAndIdsAsync, tenantId [{}], deviceIds [{}]", tenantId, deviceIds); | 147 | log.trace("Executing findDevicesByTenantIdAndIdsAsync, tenantId [{}], deviceIds [{}]", tenantId, deviceIds); |
145 | validateId(tenantId, "Incorrect tenantId " + tenantId); | 148 | validateId(tenantId, "Incorrect tenantId " + tenantId); |
146 | validateIds(deviceIds, "Incorrect deviceIds " + deviceIds); | 149 | validateIds(deviceIds, "Incorrect deviceIds " + deviceIds); |
147 | - ListenableFuture<List<Device>> devices = deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(deviceIds)); | ||
148 | - return Futures.transform(deviceEntities, (Function<List<DeviceEntity>, List<Device>>) input -> convertDataList(input)); | 150 | + return deviceDao.findDevicesByTenantIdAndIdsAsync(tenantId.getId(), toUUIDs(deviceIds)); |
149 | } | 151 | } |
150 | 152 | ||
151 | 153 | ||
@@ -163,7 +165,7 @@ public class DeviceServiceImpl implements DeviceService { | @@ -163,7 +165,7 @@ public class DeviceServiceImpl implements DeviceService { | ||
163 | validateId(customerId, "Incorrect customerId " + customerId); | 165 | validateId(customerId, "Incorrect customerId " + customerId); |
164 | validatePageLink(pageLink, "Incorrect page link " + pageLink); | 166 | validatePageLink(pageLink, "Incorrect page link " + pageLink); |
165 | List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); | 167 | List<Device> devices = deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), customerId.getId(), pageLink); |
166 | - return new TextPageData<Device>(devices, pageLink); | 168 | + return new TextPageData<>(devices, pageLink); |
167 | } | 169 | } |
168 | 170 | ||
169 | @Override | 171 | @Override |
@@ -172,9 +174,8 @@ public class DeviceServiceImpl implements DeviceService { | @@ -172,9 +174,8 @@ public class DeviceServiceImpl implements DeviceService { | ||
172 | validateId(tenantId, "Incorrect tenantId " + tenantId); | 174 | validateId(tenantId, "Incorrect tenantId " + tenantId); |
173 | validateId(customerId, "Incorrect customerId " + customerId); | 175 | validateId(customerId, "Incorrect customerId " + customerId); |
174 | validateIds(deviceIds, "Incorrect deviceIds " + deviceIds); | 176 | validateIds(deviceIds, "Incorrect deviceIds " + deviceIds); |
175 | - ListenableFuture<List<DeviceEntity>> deviceEntities = deviceDao.findDevicesByTenantIdCustomerIdAndIdsAsync(tenantId.getId(), | 177 | + return deviceDao.findDevicesByTenantIdCustomerIdAndIdsAsync(tenantId.getId(), |
176 | customerId.getId(), toUUIDs(deviceIds)); | 178 | customerId.getId(), toUUIDs(deviceIds)); |
177 | - return Futures.transform(deviceEntities, (Function<List<DeviceEntity>, List<Device>>) input -> convertDataList(input)); | ||
178 | } | 179 | } |
179 | 180 | ||
180 | @Override | 181 | @Override |
@@ -201,7 +202,7 @@ public class DeviceServiceImpl implements DeviceService { | @@ -201,7 +202,7 @@ public class DeviceServiceImpl implements DeviceService { | ||
201 | protected void validateUpdate(Device device) { | 202 | protected void validateUpdate(Device device) { |
202 | deviceDao.findDevicesByTenantIdAndName(device.getTenantId().getId(), device.getName()).ifPresent( | 203 | deviceDao.findDevicesByTenantIdAndName(device.getTenantId().getId(), device.getName()).ifPresent( |
203 | d -> { | 204 | d -> { |
204 | - if (!d.getId().equals(device.getUuidId())) { | 205 | + if (!d.getUuidId().equals(device.getUuidId())) { |
205 | throw new DataValidationException("Device with such name already exists!"); | 206 | throw new DataValidationException("Device with such name already exists!"); |
206 | } | 207 | } |
207 | } | 208 | } |
@@ -216,7 +217,7 @@ public class DeviceServiceImpl implements DeviceService { | @@ -216,7 +217,7 @@ public class DeviceServiceImpl implements DeviceService { | ||
216 | if (device.getTenantId() == null) { | 217 | if (device.getTenantId() == null) { |
217 | throw new DataValidationException("Device should be assigned to tenant!"); | 218 | throw new DataValidationException("Device should be assigned to tenant!"); |
218 | } else { | 219 | } else { |
219 | - TenantEntity tenant = tenantDao.findById(device.getTenantId().getId()); | 220 | + Tenant tenant = tenantDao.findById(device.getTenantId().getId()); |
220 | if (tenant == null) { | 221 | if (tenant == null) { |
221 | throw new DataValidationException("Device is referencing to non-existent tenant!"); | 222 | throw new DataValidationException("Device is referencing to non-existent tenant!"); |
222 | } | 223 | } |
@@ -224,32 +225,32 @@ public class DeviceServiceImpl implements DeviceService { | @@ -224,32 +225,32 @@ public class DeviceServiceImpl implements DeviceService { | ||
224 | if (device.getCustomerId() == null) { | 225 | if (device.getCustomerId() == null) { |
225 | device.setCustomerId(new CustomerId(NULL_UUID)); | 226 | device.setCustomerId(new CustomerId(NULL_UUID)); |
226 | } else if (!device.getCustomerId().getId().equals(NULL_UUID)) { | 227 | } else if (!device.getCustomerId().getId().equals(NULL_UUID)) { |
227 | - CustomerEntity customer = customerDao.findById(device.getCustomerId().getId()); | 228 | + Customer customer = customerDao.findById(device.getCustomerId().getId()); |
228 | if (customer == null) { | 229 | if (customer == null) { |
229 | throw new DataValidationException("Can't assign device to non-existent customer!"); | 230 | throw new DataValidationException("Can't assign device to non-existent customer!"); |
230 | } | 231 | } |
231 | - if (!customer.getTenantId().equals(device.getTenantId().getId())) { | 232 | + if (!customer.getTenantId().getId().equals(device.getTenantId().getId())) { |
232 | throw new DataValidationException("Can't assign device to customer from different tenant!"); | 233 | throw new DataValidationException("Can't assign device to customer from different tenant!"); |
233 | } | 234 | } |
234 | } | 235 | } |
235 | } | 236 | } |
236 | }; | 237 | }; |
237 | 238 | ||
238 | - private PaginatedRemover<TenantId, DeviceEntity> tenantDevicesRemover = | ||
239 | - new PaginatedRemover<TenantId, DeviceEntity>() { | 239 | + private PaginatedRemover<TenantId, Device> tenantDevicesRemover = |
240 | + new PaginatedRemover<TenantId, Device>() { | ||
240 | 241 | ||
241 | @Override | 242 | @Override |
242 | - protected List<DeviceEntity> findEntities(TenantId id, TextPageLink pageLink) { | 243 | + protected List<Device> findEntities(TenantId id, TextPageLink pageLink) { |
243 | return deviceDao.findDevicesByTenantId(id.getId(), pageLink); | 244 | return deviceDao.findDevicesByTenantId(id.getId(), pageLink); |
244 | } | 245 | } |
245 | 246 | ||
246 | @Override | 247 | @Override |
247 | - protected void removeEntity(DeviceEntity entity) { | ||
248 | - deleteDevice(new DeviceId(entity.getId())); | 248 | + protected void removeEntity(Device entity) { |
249 | + deleteDevice(new DeviceId(entity.getUuidId())); | ||
249 | } | 250 | } |
250 | }; | 251 | }; |
251 | 252 | ||
252 | - class CustomerDevicesUnassigner extends PaginatedRemover<CustomerId, DeviceEntity> { | 253 | + private class CustomerDevicesUnassigner extends PaginatedRemover<CustomerId, Device> { |
253 | 254 | ||
254 | private TenantId tenantId; | 255 | private TenantId tenantId; |
255 | 256 | ||
@@ -258,13 +259,13 @@ public class DeviceServiceImpl implements DeviceService { | @@ -258,13 +259,13 @@ public class DeviceServiceImpl implements DeviceService { | ||
258 | } | 259 | } |
259 | 260 | ||
260 | @Override | 261 | @Override |
261 | - protected List<DeviceEntity> findEntities(CustomerId id, TextPageLink pageLink) { | 262 | + protected List<Device> findEntities(CustomerId id, TextPageLink pageLink) { |
262 | return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink); | 263 | return deviceDao.findDevicesByTenantIdAndCustomerId(tenantId.getId(), id.getId(), pageLink); |
263 | } | 264 | } |
264 | 265 | ||
265 | @Override | 266 | @Override |
266 | - protected void removeEntity(DeviceEntity entity) { | ||
267 | - unassignDeviceFromCustomer(new DeviceId(entity.getId())); | 267 | + protected void removeEntity(Device entity) { |
268 | + unassignDeviceFromCustomer(new DeviceId(entity.getUuidId())); | ||
268 | } | 269 | } |
269 | 270 | ||
270 | } | 271 | } |
@@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; | @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; | ||
25 | import org.thingsboard.server.common.data.Event; | 25 | import org.thingsboard.server.common.data.Event; |
26 | import org.thingsboard.server.common.data.id.EntityId; | 26 | import org.thingsboard.server.common.data.id.EntityId; |
27 | import org.thingsboard.server.common.data.page.TimePageLink; | 27 | import org.thingsboard.server.common.data.page.TimePageLink; |
28 | -import org.thingsboard.server.dao.AbstractSearchTimeDao; | 28 | +import org.thingsboard.server.dao.CassandraAbstractSearchTimeDao; |
29 | import org.thingsboard.server.dao.DaoUtil; | 29 | import org.thingsboard.server.dao.DaoUtil; |
30 | import org.thingsboard.server.dao.model.EventEntity; | 30 | import org.thingsboard.server.dao.model.EventEntity; |
31 | import org.thingsboard.server.dao.model.ModelConstants; | 31 | import org.thingsboard.server.dao.model.ModelConstants; |
@@ -41,7 +41,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.*; | @@ -41,7 +41,7 @@ import static org.thingsboard.server.dao.model.ModelConstants.*; | ||
41 | 41 | ||
42 | @Component | 42 | @Component |
43 | @Slf4j | 43 | @Slf4j |
44 | -public class CassandraBaseEventDao extends AbstractSearchTimeDao<EventEntity, Event> implements EventDao { | 44 | +public class CassandraBaseEventDao extends CassandraAbstractSearchTimeDao<EventEntity, Event> implements EventDao { |
45 | 45 | ||
46 | @Override | 46 | @Override |
47 | protected Class<EventEntity> getColumnFamilyClass() { | 47 | protected Class<EventEntity> getColumnFamilyClass() { |
@@ -17,22 +17,22 @@ package org.thingsboard.server.dao.exception; | @@ -17,22 +17,22 @@ package org.thingsboard.server.dao.exception; | ||
17 | 17 | ||
18 | public class DatabaseException extends RuntimeException { | 18 | public class DatabaseException extends RuntimeException { |
19 | 19 | ||
20 | - private static final long serialVersionUID = 3463762014441887103L; | 20 | + private static final long serialVersionUID = 3463762014441887103L; |
21 | 21 | ||
22 | - public DatabaseException() { | ||
23 | - super(); | ||
24 | - } | 22 | + public DatabaseException() { |
23 | + super(); | ||
24 | + } | ||
25 | 25 | ||
26 | - public DatabaseException(String message, Throwable cause) { | ||
27 | - super(message, cause); | ||
28 | - } | 26 | + public DatabaseException(String message, Throwable cause) { |
27 | + super(message, cause); | ||
28 | + } | ||
29 | 29 | ||
30 | - public DatabaseException(String message) { | ||
31 | - super(message); | ||
32 | - } | 30 | + public DatabaseException(String message) { |
31 | + super(message); | ||
32 | + } | ||
33 | 33 | ||
34 | - public DatabaseException(Throwable cause) { | ||
35 | - super(cause); | ||
36 | - } | 34 | + public DatabaseException(Throwable cause) { |
35 | + super(cause); | ||
36 | + } | ||
37 | 37 | ||
38 | } | 38 | } |
@@ -18,9 +18,9 @@ package org.thingsboard.server.dao.exception; | @@ -18,9 +18,9 @@ package org.thingsboard.server.dao.exception; | ||
18 | 18 | ||
19 | public class IncorrectParameterException extends RuntimeException { | 19 | public class IncorrectParameterException extends RuntimeException { |
20 | 20 | ||
21 | - private static final long serialVersionUID = 601995650578985289L; | 21 | + private static final long serialVersionUID = 601995650578985289L; |
22 | 22 | ||
23 | - public IncorrectParameterException(String message) { | 23 | + public IncorrectParameterException(String message) { |
24 | super(message); | 24 | super(message); |
25 | } | 25 | } |
26 | 26 |
1 | /** | 1 | /** |
2 | * Copyright © 2016-2017 The Thingsboard Authors | 2 | * Copyright © 2016-2017 The Thingsboard Authors |
3 | - * <p> | 3 | + * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
7 | - * <p> | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * <p> | 7 | + * |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
@@ -36,11 +36,13 @@ import org.thingsboard.server.common.data.security.DeviceCredentialsType; | @@ -36,11 +36,13 @@ import org.thingsboard.server.common.data.security.DeviceCredentialsType; | ||
36 | import org.thingsboard.server.dao.device.DeviceCredentialsDao; | 36 | import org.thingsboard.server.dao.device.DeviceCredentialsDao; |
37 | import org.thingsboard.server.dao.device.DeviceCredentialsService; | 37 | import org.thingsboard.server.dao.device.DeviceCredentialsService; |
38 | import org.thingsboard.server.dao.device.DeviceService; | 38 | import org.thingsboard.server.dao.device.DeviceService; |
39 | -import org.thingsboard.server.dao.model.DeviceCredentialsEntity; | ||
40 | 39 | ||
41 | import java.util.UUID; | 40 | import java.util.UUID; |
42 | 41 | ||
43 | -import static org.mockito.Mockito.*; | 42 | +import static org.mockito.Mockito.mock; |
43 | +import static org.mockito.Mockito.times; | ||
44 | +import static org.mockito.Mockito.verify; | ||
45 | +import static org.mockito.Mockito.when; | ||
44 | 46 | ||
45 | @TestPropertySource(properties = {"cache.enabled = true"}) | 47 | @TestPropertySource(properties = {"cache.enabled = true"}) |
46 | public class DeviceCredentialsCacheTest extends AbstractServiceTest { | 48 | public class DeviceCredentialsCacheTest extends AbstractServiceTest { |
@@ -140,9 +142,8 @@ public class DeviceCredentialsCacheTest extends AbstractServiceTest { | @@ -140,9 +142,8 @@ public class DeviceCredentialsCacheTest extends AbstractServiceTest { | ||
140 | return null; | 142 | return null; |
141 | } | 143 | } |
142 | 144 | ||
143 | - private DeviceCredentialsEntity createDummyDeviceCredentialsEntity(String deviceCredentialsId) { | ||
144 | - DeviceCredentialsEntity result = new DeviceCredentialsEntity(); | ||
145 | - result.setId(UUIDs.timeBased()); | 145 | + private DeviceCredentials createDummyDeviceCredentialsEntity(String deviceCredentialsId) { |
146 | + DeviceCredentials result = new DeviceCredentials(new DeviceCredentialsId(UUIDs.timeBased())); | ||
146 | result.setCredentialsId(deviceCredentialsId); | 147 | result.setCredentialsId(deviceCredentialsId); |
147 | return result; | 148 | return result; |
148 | } | 149 | } |