thingsboard-memoizeit
Changes
dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java 8(+4 -4)
dao/src/main/java/org/thingsboard/server/dao/sql/component/JpaBaseComponentDescriptorDao.java 8(+4 -4)
dao/src/test/resources/dbunit/user.xml 14(+7 -7)
Details
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/AlarmEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/AlarmEntity.java
index 6806d6b..d807c59 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/AlarmEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/AlarmEntity.java
@@ -58,9 +58,11 @@ public final class AlarmEntity implements BaseEntity<Alarm> {
@Column(name = ALARM_TYPE_PROPERTY)
private String type;
+ @Enumerated(EnumType.STRING)
@Column(name = ALARM_SEVERITY_PROPERTY)
private AlarmSeverity severity;
+ @Enumerated(EnumType.STRING)
@Column(name = ALARM_STATUS_PROPERTY)
private AlarmStatus status;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/ComponentDescriptorEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/ComponentDescriptorEntity.java
index 02cad5d..00e34e8 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/ComponentDescriptorEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/ComponentDescriptorEntity.java
@@ -15,11 +15,8 @@
*/
package org.thingsboard.server.dao.model.sql;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
+import javax.persistence.*;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
@@ -50,9 +47,11 @@ public class ComponentDescriptorEntity implements SearchTextEntity<ComponentDesc
@Column(name = ModelConstants.ID_PROPERTY)
private UUID id;
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.COMPONENT_DESCRIPTOR_TYPE_PROPERTY)
private ComponentType type;
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.COMPONENT_DESCRIPTOR_SCOPE_PROPERTY)
private ComponentScope scope;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/DeviceCredentialsEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/DeviceCredentialsEntity.java
index b55b9b3..711e346 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/DeviceCredentialsEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/DeviceCredentialsEntity.java
@@ -16,11 +16,8 @@
package org.thingsboard.server.dao.model.sql;
import com.datastax.driver.core.utils.UUIDs;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
+
+import javax.persistence.*;
import lombok.Data;
import org.thingsboard.server.common.data.id.DeviceCredentialsId;
@@ -45,7 +42,8 @@ public final class DeviceCredentialsEntity implements BaseEntity<DeviceCredentia
@Column(name = ModelConstants.DEVICE_CREDENTIALS_DEVICE_ID_PROPERTY)
private UUID deviceId;
-
+
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.DEVICE_CREDENTIALS_CREDENTIALS_TYPE_PROPERTY)
private DeviceCredentialsType credentialsType;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/EventEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/EventEntity.java
index 65e51a0..21fe3d7 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/EventEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/EventEntity.java
@@ -16,11 +16,9 @@
package org.thingsboard.server.dao.model.sql;
import com.datastax.driver.core.utils.UUIDs;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
+
+import javax.persistence.*;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
@@ -56,6 +54,7 @@ public class EventEntity implements BaseEntity<Event> {
@Column(name = EVENT_TENANT_ID_PROPERTY)
private UUID tenantId;
+ @Enumerated(EnumType.STRING)
@Column(name = EVENT_ENTITY_TYPE_PROPERTY)
private EntityType entityType;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/PluginMetaDataEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/PluginMetaDataEntity.java
index 8d8974d..283ca35 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/PluginMetaDataEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/PluginMetaDataEntity.java
@@ -16,11 +16,9 @@
package org.thingsboard.server.dao.model.sql;
import com.datastax.driver.core.utils.UUIDs;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
+
+import javax.persistence.*;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
@@ -66,6 +64,7 @@ public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> {
@Column(name = ModelConstants.PLUGIN_ACCESS_PROPERTY)
private boolean publicAccess;
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.PLUGIN_STATE_PROPERTY)
private ComponentLifecycleState state;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/RuleMetaDataEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/RuleMetaDataEntity.java
index 193501a..77a8562 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/RuleMetaDataEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/RuleMetaDataEntity.java
@@ -17,11 +17,7 @@ package org.thingsboard.server.dao.model.sql;
import com.datastax.driver.core.utils.UUIDs;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
+import javax.persistence.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -53,27 +49,38 @@ public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> {
@Id
@Column(name = ModelConstants.ID_PROPERTY)
private UUID id;
+
@Column(name = ModelConstants.RULE_TENANT_ID_PROPERTY)
private UUID tenantId;
+
@Column(name = ModelConstants.RULE_NAME_PROPERTY)
private String name;
+
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.RULE_STATE_PROPERTY)
private ComponentLifecycleState state;
+
@Column(name = ModelConstants.RULE_WEIGHT_PROPERTY)
private int weight;
+
@Column(name = ModelConstants.SEARCH_TEXT_PROPERTY)
private String searchText;
+
@Column(name = ModelConstants.RULE_PLUGIN_TOKEN_PROPERTY)
private String pluginToken;
+
@Type(type = "jsonb")
@Column(name = ModelConstants.RULE_FILTERS, columnDefinition = "jsonb")
private JsonNode filters;
+
@Type(type = "jsonb")
@Column(name = ModelConstants.RULE_PROCESSOR, columnDefinition = "jsonb")
private JsonNode processor;
+
@Type(type = "jsonb")
@Column(name = ModelConstants.RULE_ACTION, columnDefinition = "jsonb")
private JsonNode action;
+
@Type(type = "jsonb")
@Column(name = ModelConstants.ADDITIONAL_INFO_PROPERTY, columnDefinition = "jsonb")
private JsonNode additionalInfo;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/model/sql/UserEntity.java b/dao/src/main/java/org/thingsboard/server/dao/model/sql/UserEntity.java
index 6572462..e7bc7fa 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/model/sql/UserEntity.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/model/sql/UserEntity.java
@@ -56,6 +56,7 @@ public class UserEntity implements SearchTextEntity<User> {
@Column(name = ModelConstants.USER_CUSTOMER_ID_PROPERTY)
private UUID customerId;
+ @Enumerated(EnumType.STRING)
@Column(name = ModelConstants.USER_AUTHORITY_PROPERTY)
private Authority authority;
diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java
index 9bd8c1f..ee72b2d 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/sql/component/ComponentDescriptorRepository.java
@@ -39,22 +39,22 @@ public interface ComponentDescriptorRepository extends CrudRepository<ComponentD
@Query(nativeQuery = true, value = "SELECT * FROM COMPONENT_DESCRIPTOR WHERE TYPE = ?2 " +
"AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?3, '%')) " +
"ORDER BY ID LIMIT ?1")
- List<ComponentDescriptorEntity> findByTypeFirstPage(int limit, int type, String textSearch);
+ List<ComponentDescriptorEntity> findByTypeFirstPage(int limit, String type, String textSearch);
@Query(nativeQuery = true, value = "SELECT * FROM COMPONENT_DESCRIPTOR WHERE TYPE = ?2 " +
"AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?3, '%')) " +
"AND ID > ?4 ORDER BY ID LIMIT ?1")
- List<ComponentDescriptorEntity> findByTypeNextPage(int limit, int type, String textSearch, UUID idOffset);
+ List<ComponentDescriptorEntity> findByTypeNextPage(int limit, String type, String textSearch, UUID idOffset);
@Query(nativeQuery = true, value = "SELECT * FROM COMPONENT_DESCRIPTOR WHERE TYPE = ?2 " +
"AND SCOPE = ?3 AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?4, '%')) " +
"ORDER BY ID LIMIT ?1")
- List<ComponentDescriptorEntity> findByScopeAndTypeFirstPage(int limit, int type, int scope, String textSearch);
+ List<ComponentDescriptorEntity> findByScopeAndTypeFirstPage(int limit, String type, String scope, String textSearch);
@Query(nativeQuery = true, value = "SELECT * FROM COMPONENT_DESCRIPTOR WHERE TYPE = ?2 " +
"AND SCOPE = ?3 AND LOWER(SEARCH_TEXT) LIKE LOWER(CONCAT(?4, '%')) " +
"AND ID > ?5 ORDER BY ID LIMIT ?1")
- List<ComponentDescriptorEntity> findByScopeAndTypeNextPage(int limit, int type, int scope, String textSearch, UUID idOffset);
+ List<ComponentDescriptorEntity> findByScopeAndTypeNextPage(int limit, String type, String scope, String textSearch, UUID idOffset);
void deleteByClazz(String clazz);
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/component/JpaBaseComponentDescriptorDao.java b/dao/src/main/java/org/thingsboard/server/dao/sql/component/JpaBaseComponentDescriptorDao.java
index 596d142..fec30b9 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/sql/component/JpaBaseComponentDescriptorDao.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/sql/component/JpaBaseComponentDescriptorDao.java
@@ -78,10 +78,10 @@ public class JpaBaseComponentDescriptorDao extends JpaAbstractSearchTextDao<Comp
public List<ComponentDescriptor> findByTypeAndPageLink(ComponentType type, TextPageLink pageLink) {
if (pageLink.getIdOffset() == null) {
return DaoUtil.convertDataList(componentDescriptorRepository.findByTypeFirstPage(pageLink.getLimit(),
- type.ordinal(), pageLink.getTextSearch()));
+ type.toString(), pageLink.getTextSearch()));
} else {
return DaoUtil.convertDataList(componentDescriptorRepository.findByTypeNextPage(pageLink.getLimit(),
- type.ordinal(), pageLink.getTextSearch(), pageLink.getIdOffset()));
+ type.toString(), pageLink.getTextSearch(), pageLink.getIdOffset()));
}
}
@@ -89,10 +89,10 @@ public class JpaBaseComponentDescriptorDao extends JpaAbstractSearchTextDao<Comp
public List<ComponentDescriptor> findByScopeAndTypeAndPageLink(ComponentScope scope, ComponentType type, TextPageLink pageLink) {
if (pageLink.getIdOffset() == null) {
return DaoUtil.convertDataList(componentDescriptorRepository.findByScopeAndTypeFirstPage(pageLink.getLimit(),
- type.ordinal(), scope.ordinal(), pageLink.getTextSearch()));
+ type.toString(), scope.toString(), pageLink.getTextSearch()));
} else {
return DaoUtil.convertDataList(componentDescriptorRepository.findByScopeAndTypeNextPage(pageLink.getLimit(),
- type.ordinal(), scope.ordinal(), pageLink.getTextSearch(), pageLink.getIdOffset()));
+ type.toString(), scope.toString(), pageLink.getTextSearch(), pageLink.getIdOffset()));
}
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java b/dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java
index 585bf38..b7d3aa7 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/sql/user/UserRepository.java
@@ -32,22 +32,22 @@ public interface UserRepository extends CrudRepository<UserEntity, UUID> {
UserEntity findByEmail(String email);
@Query(nativeQuery = true, value = "SELECT * FROM TB_USER WHERE TENANT_ID = ?2 " +
- "AND CUSTOMER_ID IS NULL AND AUTHORITY = 1 " +
+ "AND CUSTOMER_ID IS NULL AND AUTHORITY = 'TENANT_ADMIN' " +
"ORDER BY ID LIMIT ?1")
List<UserEntity> findTenantAdminsFirstPage(int limit, UUID tenantId);
@Query(nativeQuery = true, value = "SELECT * FROM TB_USER WHERE TENANT_ID = ?2 " +
- "AND CUSTOMER_ID IS NULL AND AUTHORITY = 1 " +
+ "AND CUSTOMER_ID IS NULL AND AUTHORITY = 'TENANT_ADMIN' " +
"AND ID > ?3 ORDER BY ID LIMIT ?1")
List<UserEntity> findTenantAdminsNextPage(int limit, UUID tenantId, UUID idOffset);
@Query(nativeQuery = true, value = "SELECT * FROM TB_USER WHERE TENANT_ID = ?2 " +
- "AND CUSTOMER_ID = ?3 AND AUTHORITY = 2 " +
+ "AND CUSTOMER_ID = ?3 AND AUTHORITY = 'CUSTOMER_USER' " +
"ORDER BY ID LIMIT ?1")
List<UserEntity> findCustomerUsersFirstPage(int limit, UUID tenantId, UUID customerId);
@Query(nativeQuery = true, value = "SELECT * FROM TB_USER WHERE TENANT_ID = ?2 " +
- "AND CUSTOMER_ID = ?3 AND AUTHORITY = 2 " +
+ "AND CUSTOMER_ID = ?3 AND AUTHORITY = 'CUSTOMER_USER' " +
"AND ID > ?4 ORDER BY ID LIMIT ?1")
List<UserEntity> findCustomerUsersNextPage(int limit, UUID tenantId, UUID customerId, UUID idOffset);
diff --git a/dao/src/test/java/org/thingsboard/server/dao/sql/user/JpaUserDaoTest.java b/dao/src/test/java/org/thingsboard/server/dao/sql/user/JpaUserDaoTest.java
index 9ec8a68..4b46918 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/sql/user/JpaUserDaoTest.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/sql/user/JpaUserDaoTest.java
@@ -113,7 +113,6 @@ public class JpaUserDaoTest extends AbstractJpaDaoTest {
userDao.save(user);
assertEquals(6, userDao.find().size());
User savedUser = userDao.findByEmail("user@thingsboard.org");
- //User savedUser = userDao.findById(UUID.fromString("cd481534-27cc-11e7-93ae-92361f002671"));
assertNotNull(savedUser);
assertEquals(additionalInfo, savedUser.getAdditionalInfo().toString());
}
diff --git a/dao/src/test/resources/dbunit/device_credentials.xml b/dao/src/test/resources/dbunit/device_credentials.xml
index aee6b1e..01ccd66 100644
--- a/dao/src/test/resources/dbunit/device_credentials.xml
+++ b/dao/src/test/resources/dbunit/device_credentials.xml
@@ -2,14 +2,14 @@
<device_credentials
id="958e3314-3215-11e7-93ae-92361f002671"
device_id="958e3a30-3215-11e7-93ae-92361f002671"
- credentials_type="0"
+ credentials_type="ACCESS_TOKEN"
credentials_id="ID_1"
credentials_value="ACCESS_TOKEN_1"
/>
<device_credentials
id="958e3c74-3215-11e7-93ae-92361f002671"
device_id="958e3e5e-3215-11e7-93ae-92361f002671"
- credentials_type="0"
+ credentials_type="ACCESS_TOKEN"
credentials_id="ID_2"
credentials_value="ACCESS_TOKEN_2"
/>
diff --git a/dao/src/test/resources/dbunit/event.xml b/dao/src/test/resources/dbunit/event.xml
index 943b45a..b150b7c 100644
--- a/dao/src/test/resources/dbunit/event.xml
+++ b/dao/src/test/resources/dbunit/event.xml
@@ -3,7 +3,7 @@
id="be41c7a2-31f5-11e7-9cfd-2786e6aa2046"
tenant_id="be41c7a0-31f5-11e7-9cfd-2786e6aa2046"
entity_id="be41c7a1-31f5-11e7-9cfd-2786e6aa2046"
- entity_type="7"
+ entity_type="DEVICE"
event_type="STATS"
event_uid="be41c7a3-31f5-11e7-9cfd-2786e6aa2046"
/>
@@ -11,7 +11,7 @@
id="be41c7a4-31f5-11e7-9cfd-2786e6aa2046"
tenant_id="be41c7a0-31f5-11e7-9cfd-2786e6aa2046"
entity_id="be41c7a1-31f5-11e7-9cfd-2786e6aa2046"
- entity_type="7"
+ entity_type="DEVICE"
event_type="STATS"
event_uid="be41c7a5-31f5-11e7-9cfd-2786e6aa2046"
/>
dao/src/test/resources/dbunit/user.xml 14(+7 -7)
diff --git a/dao/src/test/resources/dbunit/user.xml b/dao/src/test/resources/dbunit/user.xml
index 4b704a0..2127202 100644
--- a/dao/src/test/resources/dbunit/user.xml
+++ b/dao/src/test/resources/dbunit/user.xml
@@ -2,7 +2,7 @@
<tb_user id="9cb58ba0-27c1-11e7-93ae-92361f002671"
tenant_id="c97ea14e-27c1-11e7-93ae-92361f002671"
customer_id="cdf9c79e-27c1-11e7-93ae-92361f002671"
- authority="0"
+ authority="SYS_ADMIN"
email="sysadm@thingsboard.org"
search_text="SYSADM SEARCH TEXT"
first_name="John"
@@ -10,7 +10,7 @@
/>
<tb_user id="1312f328-27c7-11e7-93ae-92361f002671"
tenant_id="1e1cd4c8-27c7-11e7-93ae-92361f002671"
- authority="1"
+ authority="TENANT_ADMIN"
email="tenantadm1@thingsboard.org"
search_text="TENANTADM1 SEARCH TEXT"
first_name="Samuel"
@@ -18,7 +18,7 @@
/>
<tb_user id="2b090dde-27ca-11e7-93ae-92361f002671"
tenant_id="1e1cd4c8-27c7-11e7-93ae-92361f002671"
- authority="1"
+ authority="TENANT_ADMIN"
email="tenantadm2@thingsboard.org"
search_text="TENANTADM2 SEARCH TEXT"
first_name="Penny"
@@ -27,7 +27,7 @@
<tb_user id="cc8c1ca8-27c7-11e7-93ae-92361f002671"
tenant_id="d2e27caa-27c7-11e7-93ae-92361f002671"
customer_id="d89e128a-27c7-11e7-93ae-92361f002671"
- authority="2"
+ authority="CUSTOMER_USER"
email="customeruser@thingsboard.org"
search_text="CUSTOMER USER SEARCH TEXT"
first_name="Norman"
@@ -36,10 +36,10 @@
<tb_user id="edb2de58-27c7-11e7-93ae-92361f002671"
tenant_id="f229675e-27c7-11e7-93ae-92361f002671"
customer_id="f7a3d4e4-27c7-11e7-93ae-92361f002671"
- authority="3"
+ authority="REFRESH_TOKEN"
email="refreshtoken@thingsboard.org"
search_text="REFRESH TOKEN SEARCH TEXT"
- first_name="Dianne"
- last_name="Wensleydale"
+ first_name="Refresh"
+ last_name="Token"
/>
</dataset>
\ No newline at end of file