Commit bf7c03d49037a11763307df231272c7dd27d9d72
1 parent
2965e312
Added JPA Entity classes and someJPA Dao-related classes
Showing
59 changed files
with
3631 additions
and
180 deletions
@@ -15,8 +15,6 @@ | @@ -15,8 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.controller; | 16 | package org.thingsboard.server.controller; |
17 | 17 | ||
18 | -import com.fasterxml.jackson.databind.JsonNode; | ||
19 | -import com.fasterxml.jackson.databind.ObjectMapper; | ||
20 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
21 | import org.apache.commons.lang3.StringUtils; | 19 | import org.apache.commons.lang3.StringUtils; |
22 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -23,19 +23,16 @@ import org.thingsboard.server.common.data.Device; | @@ -23,19 +23,16 @@ import org.thingsboard.server.common.data.Device; | ||
23 | import org.thingsboard.server.common.data.id.CustomerId; | 23 | import org.thingsboard.server.common.data.id.CustomerId; |
24 | import org.thingsboard.server.common.data.id.DeviceId; | 24 | import org.thingsboard.server.common.data.id.DeviceId; |
25 | import org.thingsboard.server.common.data.id.TenantId; | 25 | import org.thingsboard.server.common.data.id.TenantId; |
26 | -import org.thingsboard.server.common.data.id.UUIDBased; | ||
27 | import org.thingsboard.server.common.data.page.TextPageData; | 26 | import org.thingsboard.server.common.data.page.TextPageData; |
28 | import org.thingsboard.server.common.data.page.TextPageLink; | 27 | import org.thingsboard.server.common.data.page.TextPageLink; |
29 | import org.thingsboard.server.common.data.security.DeviceCredentials; | 28 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
30 | import org.thingsboard.server.dao.exception.IncorrectParameterException; | 29 | import org.thingsboard.server.dao.exception.IncorrectParameterException; |
31 | import org.thingsboard.server.dao.model.ModelConstants; | 30 | import org.thingsboard.server.dao.model.ModelConstants; |
32 | import org.thingsboard.server.exception.ThingsboardException; | 31 | import org.thingsboard.server.exception.ThingsboardException; |
33 | -import org.thingsboard.server.extensions.api.device.DeviceCredentialsUpdateNotificationMsg; | ||
34 | import org.thingsboard.server.service.security.model.SecurityUser; | 32 | import org.thingsboard.server.service.security.model.SecurityUser; |
35 | 33 | ||
36 | import java.util.ArrayList; | 34 | import java.util.ArrayList; |
37 | import java.util.List; | 35 | import java.util.List; |
38 | -import java.util.UUID; | ||
39 | 36 | ||
40 | @RestController | 37 | @RestController |
41 | @RequestMapping("/api") | 38 | @RequestMapping("/api") |
@@ -25,7 +25,6 @@ import org.thingsboard.server.common.data.page.TextPageLink; | @@ -25,7 +25,6 @@ import org.thingsboard.server.common.data.page.TextPageLink; | ||
25 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; | 25 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; |
26 | import org.thingsboard.server.common.data.plugin.PluginMetaData; | 26 | import org.thingsboard.server.common.data.plugin.PluginMetaData; |
27 | import org.thingsboard.server.common.data.security.Authority; | 27 | import org.thingsboard.server.common.data.security.Authority; |
28 | -import org.thingsboard.server.common.data.widget.WidgetsBundle; | ||
29 | import org.thingsboard.server.dao.model.ModelConstants; | 28 | import org.thingsboard.server.dao.model.ModelConstants; |
30 | import org.thingsboard.server.exception.ThingsboardException; | 29 | import org.thingsboard.server.exception.ThingsboardException; |
31 | 30 |
@@ -188,3 +188,15 @@ cache: | @@ -188,3 +188,15 @@ cache: | ||
188 | updates: | 188 | updates: |
189 | # Enable/disable updates checking. | 189 | # Enable/disable updates checking. |
190 | enabled: "${UPDATES_ENABLED:true}" | 190 | enabled: "${UPDATES_ENABLED:true}" |
191 | + | ||
192 | +cassandra: | ||
193 | + enabled: "${CASSANDRA_ENABLED:true}" | ||
194 | + | ||
195 | +# SQL DAO Configuration | ||
196 | + | ||
197 | +sql: | ||
198 | + enabled: "${SQL_ENABLED:false}" | ||
199 | + datasource: | ||
200 | + url: "${SQL_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}" | ||
201 | + username: "${SQL_DATASOURCE_USERNAME:postgres}" | ||
202 | + password: "${SQL_DATASOURCE_PASSWORD:postgres}" |
@@ -150,6 +150,10 @@ | @@ -150,6 +150,10 @@ | ||
150 | <groupId>org.bouncycastle</groupId> | 150 | <groupId>org.bouncycastle</groupId> |
151 | <artifactId>bcprov-jdk15on</artifactId> | 151 | <artifactId>bcprov-jdk15on</artifactId> |
152 | </dependency> | 152 | </dependency> |
153 | + <dependency> | ||
154 | + <groupId>org.springframework.boot</groupId> | ||
155 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | ||
156 | + </dependency> | ||
153 | </dependencies> | 157 | </dependencies> |
154 | <build> | 158 | <build> |
155 | <plugins> | 159 | <plugins> |
@@ -27,7 +27,6 @@ import com.google.common.base.Function; | @@ -27,7 +27,6 @@ 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; | ||
31 | import org.thingsboard.server.dao.model.BaseEntity; | 30 | import org.thingsboard.server.dao.model.BaseEntity; |
32 | import org.thingsboard.server.dao.model.ModelConstants; | 31 | import org.thingsboard.server.dao.model.ModelConstants; |
33 | import org.thingsboard.server.dao.model.SearchTextEntity; | 32 | import org.thingsboard.server.dao.model.SearchTextEntity; |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao; | ||
17 | + | ||
18 | +import org.springframework.beans.factory.annotation.Value; | ||
19 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
20 | +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; | ||
21 | +import org.springframework.context.annotation.Configuration; | ||
22 | + | ||
23 | +import javax.sql.DataSource; | ||
24 | + | ||
25 | +/** | ||
26 | + * @author Valerii Sosliuk | ||
27 | + */ | ||
28 | +@Configuration | ||
29 | +@ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) | ||
30 | +public class JpaDaoConfig { | ||
31 | + | ||
32 | + @Value("sql.datasource.url") | ||
33 | + private String url; | ||
34 | + @Value("sql.datasource.username") | ||
35 | + private String username; | ||
36 | + @Value("sql.datasource.password") | ||
37 | + private String password; | ||
38 | + | ||
39 | + public DataSource dataSource() { | ||
40 | + return DataSourceBuilder.create().url(url).username(username).password(password).build(); | ||
41 | + } | ||
42 | +} |
@@ -29,7 +29,7 @@ import org.thingsboard.server.common.data.plugin.ComponentScope; | @@ -29,7 +29,7 @@ import org.thingsboard.server.common.data.plugin.ComponentScope; | ||
29 | import org.thingsboard.server.common.data.plugin.ComponentType; | 29 | import org.thingsboard.server.common.data.plugin.ComponentType; |
30 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 30 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
31 | import org.thingsboard.server.dao.DaoUtil; | 31 | import org.thingsboard.server.dao.DaoUtil; |
32 | -import org.thingsboard.server.dao.model.ComponentDescriptorEntity; | 32 | +import org.thingsboard.server.dao.model.nosql.ComponentDescriptorEntity; |
33 | import org.thingsboard.server.dao.model.ModelConstants; | 33 | import org.thingsboard.server.dao.model.ModelConstants; |
34 | 34 | ||
35 | import java.util.Arrays; | 35 | import java.util.Arrays; |
@@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.Customer; | @@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.Customer; | ||
21 | import org.thingsboard.server.common.data.page.TextPageLink; | 21 | import org.thingsboard.server.common.data.page.TextPageLink; |
22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.CustomerEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.CustomerEntity; |
25 | import org.thingsboard.server.dao.model.ModelConstants; | 25 | import org.thingsboard.server.dao.model.ModelConstants; |
26 | 26 | ||
27 | import java.util.Arrays; | 27 | import java.util.Arrays; |
@@ -18,7 +18,7 @@ package org.thingsboard.server.dao.dashboard; | @@ -18,7 +18,7 @@ package org.thingsboard.server.dao.dashboard; | ||
18 | import org.springframework.stereotype.Component; | 18 | import org.springframework.stereotype.Component; |
19 | import org.thingsboard.server.common.data.Dashboard; | 19 | import org.thingsboard.server.common.data.Dashboard; |
20 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 20 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
21 | -import org.thingsboard.server.dao.model.DashboardEntity; | 21 | +import org.thingsboard.server.dao.model.nosql.DashboardEntity; |
22 | 22 | ||
23 | import static org.thingsboard.server.dao.model.ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME; | 23 | import static org.thingsboard.server.dao.model.ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME; |
24 | 24 |
@@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.DashboardInfo; | @@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.DashboardInfo; | ||
21 | import org.thingsboard.server.common.data.page.TextPageLink; | 21 | import org.thingsboard.server.common.data.page.TextPageLink; |
22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.DashboardInfoEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.DashboardInfoEntity; |
25 | 25 | ||
26 | import java.util.Arrays; | 26 | import java.util.Arrays; |
27 | import java.util.Collections; | 27 | import java.util.Collections; |
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | ||
21 | import org.thingsboard.server.common.data.security.DeviceCredentials; | 21 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.DeviceCredentialsEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.DeviceCredentialsEntity; |
25 | import org.thingsboard.server.dao.model.ModelConstants; | 25 | import org.thingsboard.server.dao.model.ModelConstants; |
26 | 26 | ||
27 | import java.util.UUID; | 27 | import java.util.UUID; |
@@ -23,7 +23,7 @@ import org.thingsboard.server.common.data.Device; | @@ -23,7 +23,7 @@ import org.thingsboard.server.common.data.Device; | ||
23 | import org.thingsboard.server.common.data.page.TextPageLink; | 23 | import org.thingsboard.server.common.data.page.TextPageLink; |
24 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 24 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
25 | import org.thingsboard.server.dao.DaoUtil; | 25 | import org.thingsboard.server.dao.DaoUtil; |
26 | -import org.thingsboard.server.dao.model.DeviceEntity; | 26 | +import org.thingsboard.server.dao.model.nosql.DeviceEntity; |
27 | 27 | ||
28 | import java.util.*; | 28 | import java.util.*; |
29 | 29 |
@@ -15,8 +15,6 @@ | @@ -15,8 +15,6 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.dao.device; | 16 | package org.thingsboard.server.dao.device; |
17 | 17 | ||
18 | -import com.google.common.base.Function; | ||
19 | -import com.google.common.util.concurrent.Futures; | ||
20 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
21 | import lombok.extern.slf4j.Slf4j; | 19 | import lombok.extern.slf4j.Slf4j; |
22 | import org.apache.commons.lang3.RandomStringUtils; | 20 | import org.apache.commons.lang3.RandomStringUtils; |
@@ -35,7 +33,6 @@ import org.thingsboard.server.common.data.security.DeviceCredentials; | @@ -35,7 +33,6 @@ import org.thingsboard.server.common.data.security.DeviceCredentials; | ||
35 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; | 33 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
36 | import org.thingsboard.server.dao.customer.CustomerDao; | 34 | import org.thingsboard.server.dao.customer.CustomerDao; |
37 | import org.thingsboard.server.dao.exception.DataValidationException; | 35 | import org.thingsboard.server.dao.exception.DataValidationException; |
38 | -import org.thingsboard.server.dao.model.DeviceEntity; | ||
39 | import org.thingsboard.server.dao.service.DataValidator; | 36 | import org.thingsboard.server.dao.service.DataValidator; |
40 | import org.thingsboard.server.dao.service.PaginatedRemover; | 37 | import org.thingsboard.server.dao.service.PaginatedRemover; |
41 | import org.thingsboard.server.dao.tenant.TenantDao; | 38 | import org.thingsboard.server.dao.tenant.TenantDao; |
@@ -43,8 +40,6 @@ import org.thingsboard.server.dao.tenant.TenantDao; | @@ -43,8 +40,6 @@ import org.thingsboard.server.dao.tenant.TenantDao; | ||
43 | import java.util.List; | 40 | import java.util.List; |
44 | import java.util.Optional; | 41 | import java.util.Optional; |
45 | 42 | ||
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; | 43 | import static org.thingsboard.server.dao.DaoUtil.toUUIDs; |
49 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; | 44 | import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID; |
50 | import static org.thingsboard.server.dao.service.Validator.validateId; | 45 | import static org.thingsboard.server.dao.service.Validator.validateId; |
@@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.id.TenantId; | @@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.id.TenantId; | ||
30 | import org.thingsboard.server.common.data.page.TimePageLink; | 30 | import org.thingsboard.server.common.data.page.TimePageLink; |
31 | import org.thingsboard.server.dao.CassandraAbstractSearchTimeDao; | 31 | import org.thingsboard.server.dao.CassandraAbstractSearchTimeDao; |
32 | import org.thingsboard.server.dao.DaoUtil; | 32 | import org.thingsboard.server.dao.DaoUtil; |
33 | -import org.thingsboard.server.dao.model.EventEntity; | 33 | +import org.thingsboard.server.dao.model.nosql.EventEntity; |
34 | import org.thingsboard.server.dao.model.ModelConstants; | 34 | import org.thingsboard.server.dao.model.ModelConstants; |
35 | 35 | ||
36 | import java.util.Arrays; | 36 | import java.util.Arrays; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/AdminSettingsEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/AdminSettingsEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import static org.thingsboard.server.dao.model.ModelConstants.ADMIN_SETTINGS_COLUMN_FAMILY_NAME; | 18 | import static org.thingsboard.server.dao.model.ModelConstants.ADMIN_SETTINGS_COLUMN_FAMILY_NAME; |
19 | import static org.thingsboard.server.dao.model.ModelConstants.ADMIN_SETTINGS_JSON_VALUE_PROPERTY; | 19 | import static org.thingsboard.server.dao.model.ModelConstants.ADMIN_SETTINGS_JSON_VALUE_PROPERTY; |
@@ -24,6 +24,7 @@ import java.util.UUID; | @@ -24,6 +24,7 @@ import java.util.UUID; | ||
24 | 24 | ||
25 | import org.thingsboard.server.common.data.AdminSettings; | 25 | import org.thingsboard.server.common.data.AdminSettings; |
26 | import org.thingsboard.server.common.data.id.AdminSettingsId; | 26 | import org.thingsboard.server.common.data.id.AdminSettingsId; |
27 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
27 | import org.thingsboard.server.dao.model.type.JsonCodec; | 28 | import org.thingsboard.server.dao.model.type.JsonCodec; |
28 | 29 | ||
29 | import com.datastax.driver.core.utils.UUIDs; | 30 | import com.datastax.driver.core.utils.UUIDs; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/ComponentDescriptorEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/ComponentDescriptorEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.mapping.annotations.Column; | 18 | import com.datastax.driver.mapping.annotations.Column; |
19 | import com.datastax.driver.mapping.annotations.PartitionKey; | 19 | import com.datastax.driver.mapping.annotations.PartitionKey; |
@@ -23,6 +23,8 @@ import org.thingsboard.server.common.data.id.ComponentDescriptorId; | @@ -23,6 +23,8 @@ import org.thingsboard.server.common.data.id.ComponentDescriptorId; | ||
23 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; | 23 | import org.thingsboard.server.common.data.plugin.ComponentDescriptor; |
24 | import org.thingsboard.server.common.data.plugin.ComponentScope; | 24 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
25 | import org.thingsboard.server.common.data.plugin.ComponentType; | 25 | import org.thingsboard.server.common.data.plugin.ComponentType; |
26 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
27 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
26 | import org.thingsboard.server.dao.model.type.JsonCodec; | 28 | import org.thingsboard.server.dao.model.type.JsonCodec; |
27 | 29 | ||
28 | import java.util.UUID; | 30 | import java.util.UUID; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/CustomerEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/CustomerEntity.java
@@ -13,28 +13,15 @@ | @@ -13,28 +13,15 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | ||
17 | - | ||
18 | -import static org.thingsboard.server.dao.model.ModelConstants.ADDRESS2_PROPERTY; | ||
19 | -import static org.thingsboard.server.dao.model.ModelConstants.ADDRESS_PROPERTY; | ||
20 | -import static org.thingsboard.server.dao.model.ModelConstants.CITY_PROPERTY; | ||
21 | -import static org.thingsboard.server.dao.model.ModelConstants.COUNTRY_PROPERTY; | ||
22 | -import static org.thingsboard.server.dao.model.ModelConstants.CUSTOMER_ADDITIONAL_INFO_PROPERTY; | ||
23 | -import static org.thingsboard.server.dao.model.ModelConstants.CUSTOMER_COLUMN_FAMILY_NAME; | ||
24 | -import static org.thingsboard.server.dao.model.ModelConstants.CUSTOMER_TENANT_ID_PROPERTY; | ||
25 | -import static org.thingsboard.server.dao.model.ModelConstants.CUSTOMER_TITLE_PROPERTY; | ||
26 | -import static org.thingsboard.server.dao.model.ModelConstants.EMAIL_PROPERTY; | ||
27 | -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | ||
28 | -import static org.thingsboard.server.dao.model.ModelConstants.PHONE_PROPERTY; | ||
29 | -import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY; | ||
30 | -import static org.thingsboard.server.dao.model.ModelConstants.STATE_PROPERTY; | ||
31 | -import static org.thingsboard.server.dao.model.ModelConstants.ZIP_PROPERTY; | 16 | +package org.thingsboard.server.dao.model.nosql; |
32 | 17 | ||
33 | import java.util.UUID; | 18 | import java.util.UUID; |
34 | 19 | ||
35 | import org.thingsboard.server.common.data.Customer; | 20 | import org.thingsboard.server.common.data.Customer; |
36 | import org.thingsboard.server.common.data.id.CustomerId; | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
37 | import org.thingsboard.server.common.data.id.TenantId; | 22 | import org.thingsboard.server.common.data.id.TenantId; |
23 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
24 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
38 | import org.thingsboard.server.dao.model.type.JsonCodec; | 25 | import org.thingsboard.server.dao.model.type.JsonCodec; |
39 | 26 | ||
40 | import com.datastax.driver.core.utils.UUIDs; | 27 | import com.datastax.driver.core.utils.UUIDs; |
@@ -44,51 +31,51 @@ import com.datastax.driver.mapping.annotations.Table; | @@ -44,51 +31,51 @@ import com.datastax.driver.mapping.annotations.Table; | ||
44 | import com.datastax.driver.mapping.annotations.Transient; | 31 | import com.datastax.driver.mapping.annotations.Transient; |
45 | import com.fasterxml.jackson.databind.JsonNode; | 32 | import com.fasterxml.jackson.databind.JsonNode; |
46 | 33 | ||
47 | -@Table(name = CUSTOMER_COLUMN_FAMILY_NAME) | 34 | +@Table(name = ModelConstants.CUSTOMER_COLUMN_FAMILY_NAME) |
48 | public final class CustomerEntity implements SearchTextEntity<Customer> { | 35 | public final class CustomerEntity implements SearchTextEntity<Customer> { |
49 | 36 | ||
50 | @Transient | 37 | @Transient |
51 | private static final long serialVersionUID = -7732527103760948490L; | 38 | private static final long serialVersionUID = -7732527103760948490L; |
52 | 39 | ||
53 | @PartitionKey(value = 0) | 40 | @PartitionKey(value = 0) |
54 | - @Column(name = ID_PROPERTY) | 41 | + @Column(name = ModelConstants.ID_PROPERTY) |
55 | private UUID id; | 42 | private UUID id; |
56 | 43 | ||
57 | @PartitionKey(value = 1) | 44 | @PartitionKey(value = 1) |
58 | - @Column(name = CUSTOMER_TENANT_ID_PROPERTY) | 45 | + @Column(name = ModelConstants.CUSTOMER_TENANT_ID_PROPERTY) |
59 | private UUID tenantId; | 46 | private UUID tenantId; |
60 | 47 | ||
61 | - @Column(name = CUSTOMER_TITLE_PROPERTY) | 48 | + @Column(name = ModelConstants.CUSTOMER_TITLE_PROPERTY) |
62 | private String title; | 49 | private String title; |
63 | 50 | ||
64 | - @Column(name = SEARCH_TEXT_PROPERTY) | 51 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
65 | private String searchText; | 52 | private String searchText; |
66 | 53 | ||
67 | - @Column(name = COUNTRY_PROPERTY) | 54 | + @Column(name = ModelConstants.COUNTRY_PROPERTY) |
68 | private String country; | 55 | private String country; |
69 | 56 | ||
70 | - @Column(name = STATE_PROPERTY) | 57 | + @Column(name = ModelConstants.STATE_PROPERTY) |
71 | private String state; | 58 | private String state; |
72 | 59 | ||
73 | - @Column(name = CITY_PROPERTY) | 60 | + @Column(name = ModelConstants.CITY_PROPERTY) |
74 | private String city; | 61 | private String city; |
75 | 62 | ||
76 | - @Column(name = ADDRESS_PROPERTY) | 63 | + @Column(name = ModelConstants.ADDRESS_PROPERTY) |
77 | private String address; | 64 | private String address; |
78 | 65 | ||
79 | - @Column(name = ADDRESS2_PROPERTY) | 66 | + @Column(name = ModelConstants.ADDRESS2_PROPERTY) |
80 | private String address2; | 67 | private String address2; |
81 | 68 | ||
82 | - @Column(name = ZIP_PROPERTY) | 69 | + @Column(name = ModelConstants.ZIP_PROPERTY) |
83 | private String zip; | 70 | private String zip; |
84 | 71 | ||
85 | - @Column(name = PHONE_PROPERTY) | 72 | + @Column(name = ModelConstants.PHONE_PROPERTY) |
86 | private String phone; | 73 | private String phone; |
87 | 74 | ||
88 | - @Column(name = EMAIL_PROPERTY) | 75 | + @Column(name = ModelConstants.EMAIL_PROPERTY) |
89 | private String email; | 76 | private String email; |
90 | 77 | ||
91 | - @Column(name = CUSTOMER_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 78 | + @Column(name = ModelConstants.CUSTOMER_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
92 | private JsonNode additionalInfo; | 79 | private JsonNode additionalInfo; |
93 | 80 | ||
94 | public CustomerEntity() { | 81 | public CustomerEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/DashboardEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/DashboardEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import java.util.UUID; | 18 | import java.util.UUID; |
19 | 19 | ||
@@ -21,6 +21,8 @@ import org.thingsboard.server.common.data.Dashboard; | @@ -21,6 +21,8 @@ import org.thingsboard.server.common.data.Dashboard; | ||
21 | import org.thingsboard.server.common.data.id.CustomerId; | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
22 | import org.thingsboard.server.common.data.id.DashboardId; | 22 | import org.thingsboard.server.common.data.id.DashboardId; |
23 | import org.thingsboard.server.common.data.id.TenantId; | 23 | import org.thingsboard.server.common.data.id.TenantId; |
24 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
25 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
24 | import org.thingsboard.server.dao.model.type.JsonCodec; | 26 | import org.thingsboard.server.dao.model.type.JsonCodec; |
25 | 27 | ||
26 | import com.datastax.driver.core.utils.UUIDs; | 28 | import com.datastax.driver.core.utils.UUIDs; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/DashboardInfoEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/DashboardInfoEntity.java
@@ -13,23 +13,22 @@ | @@ -13,23 +13,22 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import java.util.UUID; | 18 | import java.util.UUID; |
19 | 19 | ||
20 | -import org.thingsboard.server.common.data.Dashboard; | ||
21 | import org.thingsboard.server.common.data.DashboardInfo; | 20 | import org.thingsboard.server.common.data.DashboardInfo; |
22 | import org.thingsboard.server.common.data.id.CustomerId; | 21 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | import org.thingsboard.server.common.data.id.DashboardId; | 22 | import org.thingsboard.server.common.data.id.DashboardId; |
24 | import org.thingsboard.server.common.data.id.TenantId; | 23 | import org.thingsboard.server.common.data.id.TenantId; |
25 | -import org.thingsboard.server.dao.model.type.JsonCodec; | 24 | +import org.thingsboard.server.dao.model.ModelConstants; |
25 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
26 | 26 | ||
27 | import com.datastax.driver.core.utils.UUIDs; | 27 | import com.datastax.driver.core.utils.UUIDs; |
28 | import com.datastax.driver.mapping.annotations.Column; | 28 | import com.datastax.driver.mapping.annotations.Column; |
29 | import com.datastax.driver.mapping.annotations.PartitionKey; | 29 | import com.datastax.driver.mapping.annotations.PartitionKey; |
30 | import com.datastax.driver.mapping.annotations.Table; | 30 | import com.datastax.driver.mapping.annotations.Table; |
31 | import com.datastax.driver.mapping.annotations.Transient; | 31 | import com.datastax.driver.mapping.annotations.Transient; |
32 | -import com.fasterxml.jackson.databind.JsonNode; | ||
33 | 32 | ||
34 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) | 33 | @Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) |
35 | public class DashboardInfoEntity implements SearchTextEntity<DashboardInfo> { | 34 | public class DashboardInfoEntity implements SearchTextEntity<DashboardInfo> { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/DeviceCredentialsEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/DeviceCredentialsEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import java.util.UUID; | 18 | import java.util.UUID; |
19 | 19 | ||
@@ -21,6 +21,8 @@ import org.thingsboard.server.common.data.id.DeviceCredentialsId; | @@ -21,6 +21,8 @@ import org.thingsboard.server.common.data.id.DeviceCredentialsId; | ||
21 | import org.thingsboard.server.common.data.id.DeviceId; | 21 | import org.thingsboard.server.common.data.id.DeviceId; |
22 | import org.thingsboard.server.common.data.security.DeviceCredentials; | 22 | import org.thingsboard.server.common.data.security.DeviceCredentials; |
23 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; | 23 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
24 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
25 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
24 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; | 26 | import org.thingsboard.server.dao.model.type.DeviceCredentialsTypeCodec; |
25 | 27 | ||
26 | import com.datastax.driver.core.utils.UUIDs; | 28 | import com.datastax.driver.core.utils.UUIDs; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/DeviceEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/DeviceEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | import com.datastax.driver.mapping.annotations.Column; | 19 | import com.datastax.driver.mapping.annotations.Column; |
@@ -25,37 +25,37 @@ import org.thingsboard.server.common.data.Device; | @@ -25,37 +25,37 @@ import org.thingsboard.server.common.data.Device; | ||
25 | import org.thingsboard.server.common.data.id.CustomerId; | 25 | import org.thingsboard.server.common.data.id.CustomerId; |
26 | import org.thingsboard.server.common.data.id.DeviceId; | 26 | import org.thingsboard.server.common.data.id.DeviceId; |
27 | import org.thingsboard.server.common.data.id.TenantId; | 27 | import org.thingsboard.server.common.data.id.TenantId; |
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
28 | import org.thingsboard.server.dao.model.type.JsonCodec; | 30 | import org.thingsboard.server.dao.model.type.JsonCodec; |
29 | 31 | ||
30 | import java.util.UUID; | 32 | import java.util.UUID; |
31 | 33 | ||
32 | -import static org.thingsboard.server.dao.model.ModelConstants.*; | ||
33 | - | ||
34 | -@Table(name = DEVICE_COLUMN_FAMILY_NAME) | 34 | +@Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) |
35 | public final class DeviceEntity implements SearchTextEntity<Device> { | 35 | public final class DeviceEntity implements SearchTextEntity<Device> { |
36 | 36 | ||
37 | @Transient | 37 | @Transient |
38 | private static final long serialVersionUID = -1265181166886910152L; | 38 | private static final long serialVersionUID = -1265181166886910152L; |
39 | 39 | ||
40 | @PartitionKey(value = 0) | 40 | @PartitionKey(value = 0) |
41 | - @Column(name = ID_PROPERTY) | 41 | + @Column(name = ModelConstants.ID_PROPERTY) |
42 | private UUID id; | 42 | private UUID id; |
43 | 43 | ||
44 | @PartitionKey(value = 1) | 44 | @PartitionKey(value = 1) |
45 | - @Column(name = DEVICE_TENANT_ID_PROPERTY) | 45 | + @Column(name = ModelConstants.DEVICE_TENANT_ID_PROPERTY) |
46 | private UUID tenantId; | 46 | private UUID tenantId; |
47 | 47 | ||
48 | @PartitionKey(value = 2) | 48 | @PartitionKey(value = 2) |
49 | - @Column(name = DEVICE_CUSTOMER_ID_PROPERTY) | 49 | + @Column(name = ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY) |
50 | private UUID customerId; | 50 | private UUID customerId; |
51 | 51 | ||
52 | - @Column(name = DEVICE_NAME_PROPERTY) | 52 | + @Column(name = ModelConstants.DEVICE_NAME_PROPERTY) |
53 | private String name; | 53 | private String name; |
54 | 54 | ||
55 | - @Column(name = SEARCH_TEXT_PROPERTY) | 55 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
56 | private String searchText; | 56 | private String searchText; |
57 | 57 | ||
58 | - @Column(name = DEVICE_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 58 | + @Column(name = ModelConstants.DEVICE_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
59 | private JsonNode additionalInfo; | 59 | private JsonNode additionalInfo; |
60 | 60 | ||
61 | public DeviceEntity() { | 61 | public DeviceEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/EventEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/EventEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | import com.datastax.driver.mapping.annotations.*; | 19 | import com.datastax.driver.mapping.annotations.*; |
@@ -23,48 +23,48 @@ import lombok.NoArgsConstructor; | @@ -23,48 +23,48 @@ import lombok.NoArgsConstructor; | ||
23 | import org.thingsboard.server.common.data.EntityType; | 23 | import org.thingsboard.server.common.data.EntityType; |
24 | import org.thingsboard.server.common.data.Event; | 24 | import org.thingsboard.server.common.data.Event; |
25 | import org.thingsboard.server.common.data.id.*; | 25 | import org.thingsboard.server.common.data.id.*; |
26 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
27 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
26 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; | 28 | import org.thingsboard.server.dao.model.type.EntityTypeCodec; |
27 | import org.thingsboard.server.dao.model.type.JsonCodec; | 29 | import org.thingsboard.server.dao.model.type.JsonCodec; |
28 | 30 | ||
29 | import java.util.UUID; | 31 | import java.util.UUID; |
30 | 32 | ||
31 | -import static org.thingsboard.server.dao.model.ModelConstants.*; | ||
32 | - | ||
33 | /** | 33 | /** |
34 | * @author Andrew Shvayka | 34 | * @author Andrew Shvayka |
35 | */ | 35 | */ |
36 | @Data | 36 | @Data |
37 | @NoArgsConstructor | 37 | @NoArgsConstructor |
38 | -@Table(name = DEVICE_COLUMN_FAMILY_NAME) | 38 | +@Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) |
39 | public class EventEntity implements BaseEntity<Event> { | 39 | public class EventEntity implements BaseEntity<Event> { |
40 | 40 | ||
41 | @Transient | 41 | @Transient |
42 | private static final long serialVersionUID = -1265181166886910153L; | 42 | private static final long serialVersionUID = -1265181166886910153L; |
43 | 43 | ||
44 | - @Column(name = ID_PROPERTY) | 44 | + @Column(name = ModelConstants.ID_PROPERTY) |
45 | private UUID id; | 45 | private UUID id; |
46 | 46 | ||
47 | @PartitionKey() | 47 | @PartitionKey() |
48 | - @Column(name = EVENT_TENANT_ID_PROPERTY) | 48 | + @Column(name = ModelConstants.EVENT_TENANT_ID_PROPERTY) |
49 | private UUID tenantId; | 49 | private UUID tenantId; |
50 | 50 | ||
51 | @PartitionKey(value = 1) | 51 | @PartitionKey(value = 1) |
52 | - @Column(name = EVENT_ENTITY_TYPE_PROPERTY, codec = EntityTypeCodec.class) | 52 | + @Column(name = ModelConstants.EVENT_ENTITY_TYPE_PROPERTY, codec = EntityTypeCodec.class) |
53 | private EntityType entityType; | 53 | private EntityType entityType; |
54 | 54 | ||
55 | @PartitionKey(value = 2) | 55 | @PartitionKey(value = 2) |
56 | - @Column(name = EVENT_ENTITY_ID_PROPERTY) | 56 | + @Column(name = ModelConstants.EVENT_ENTITY_ID_PROPERTY) |
57 | private UUID entityId; | 57 | private UUID entityId; |
58 | 58 | ||
59 | @ClusteringColumn() | 59 | @ClusteringColumn() |
60 | - @Column(name = EVENT_TYPE_PROPERTY) | 60 | + @Column(name = ModelConstants.EVENT_TYPE_PROPERTY) |
61 | private String eventType; | 61 | private String eventType; |
62 | 62 | ||
63 | @ClusteringColumn(value = 1) | 63 | @ClusteringColumn(value = 1) |
64 | - @Column(name = EVENT_UID_PROPERTY) | 64 | + @Column(name = ModelConstants.EVENT_UID_PROPERTY) |
65 | private String eventUId; | 65 | private String eventUId; |
66 | 66 | ||
67 | - @Column(name = EVENT_BODY_PROPERTY, codec = JsonCodec.class) | 67 | + @Column(name = ModelConstants.EVENT_BODY_PROPERTY, codec = JsonCodec.class) |
68 | private JsonNode body; | 68 | private JsonNode body; |
69 | 69 | ||
70 | public EventEntity(Event event) { | 70 | public EventEntity(Event event) { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/PluginMetaDataEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/PluginMetaDataEntity.java
@@ -13,31 +13,28 @@ | @@ -13,31 +13,28 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | -import com.datastax.driver.mapping.annotations.ClusteringColumn; | ||
20 | -import com.datastax.driver.mapping.annotations.Column; | ||
21 | -import com.datastax.driver.mapping.annotations.PartitionKey; | ||
22 | -import com.datastax.driver.mapping.annotations.Table; | 19 | +import com.datastax.driver.mapping.annotations.*; |
23 | import com.fasterxml.jackson.databind.JsonNode; | 20 | import com.fasterxml.jackson.databind.JsonNode; |
24 | import org.thingsboard.server.common.data.id.PluginId; | 21 | import org.thingsboard.server.common.data.id.PluginId; |
25 | import org.thingsboard.server.common.data.id.TenantId; | 22 | import org.thingsboard.server.common.data.id.TenantId; |
26 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; | 23 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; |
27 | import org.thingsboard.server.common.data.plugin.PluginMetaData; | 24 | import org.thingsboard.server.common.data.plugin.PluginMetaData; |
25 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
26 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
28 | import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | 27 | import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; |
29 | import org.thingsboard.server.dao.model.type.JsonCodec; | 28 | import org.thingsboard.server.dao.model.type.JsonCodec; |
30 | 29 | ||
31 | import java.util.Objects; | 30 | import java.util.Objects; |
32 | import java.util.UUID; | 31 | import java.util.UUID; |
33 | 32 | ||
34 | -import static org.thingsboard.server.dao.model.ModelConstants.ADDITIONAL_INFO_PROPERTY; | ||
35 | -import static org.thingsboard.server.dao.model.ModelConstants.RULE_ACTION; | ||
36 | - | ||
37 | @Table(name = ModelConstants.PLUGIN_COLUMN_FAMILY_NAME) | 33 | @Table(name = ModelConstants.PLUGIN_COLUMN_FAMILY_NAME) |
38 | public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { | 34 | public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { |
39 | 35 | ||
40 | - private static final long serialVersionUID = 1L; | 36 | + @Transient |
37 | + private static final long serialVersionUID = -5231612734979707866L; | ||
41 | 38 | ||
42 | @PartitionKey | 39 | @PartitionKey |
43 | @Column(name = ModelConstants.ID_PROPERTY) | 40 | @Column(name = ModelConstants.ID_PROPERTY) |
@@ -68,7 +65,7 @@ public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { | @@ -68,7 +65,7 @@ public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { | ||
68 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | 65 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
69 | private String searchText; | 66 | private String searchText; |
70 | 67 | ||
71 | - @Column(name = ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 68 | + @Column(name = ModelConstants.ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
72 | private JsonNode additionalInfo; | 69 | private JsonNode additionalInfo; |
73 | 70 | ||
74 | public PluginMetaDataEntity() { | 71 | public PluginMetaDataEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/RuleMetaDataEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/RuleMetaDataEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | import com.datastax.driver.mapping.annotations.ClusteringColumn; | 19 | import com.datastax.driver.mapping.annotations.ClusteringColumn; |
@@ -26,40 +26,43 @@ import org.thingsboard.server.common.data.id.TenantId; | @@ -26,40 +26,43 @@ import org.thingsboard.server.common.data.id.TenantId; | ||
26 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; | 26 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; |
27 | import org.thingsboard.server.common.data.rule.RuleMetaData; | 27 | import org.thingsboard.server.common.data.rule.RuleMetaData; |
28 | import org.thingsboard.server.dao.DaoUtil; | 28 | import org.thingsboard.server.dao.DaoUtil; |
29 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
29 | import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; | 31 | import org.thingsboard.server.dao.model.type.ComponentLifecycleStateCodec; |
30 | import org.thingsboard.server.dao.model.type.JsonCodec; | 32 | import org.thingsboard.server.dao.model.type.JsonCodec; |
31 | 33 | ||
34 | +import javax.persistence.Transient; | ||
32 | import java.util.Objects; | 35 | import java.util.Objects; |
33 | import java.util.UUID; | 36 | import java.util.UUID; |
34 | 37 | ||
35 | -import static org.thingsboard.server.dao.model.ModelConstants.*; | ||
36 | - | ||
37 | -@Table(name = RULE_COLUMN_FAMILY_NAME) | 38 | +@Table(name = ModelConstants.RULE_COLUMN_FAMILY_NAME) |
38 | public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> { | 39 | public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> { |
39 | 40 | ||
41 | + @Transient | ||
42 | + private static final long serialVersionUID = 4011728715100800304L; | ||
40 | @PartitionKey | 43 | @PartitionKey |
41 | - @Column(name = ID_PROPERTY) | 44 | + @Column(name = ModelConstants.ID_PROPERTY) |
42 | private UUID id; | 45 | private UUID id; |
43 | @ClusteringColumn | 46 | @ClusteringColumn |
44 | - @Column(name = RULE_TENANT_ID_PROPERTY) | 47 | + @Column(name = ModelConstants.RULE_TENANT_ID_PROPERTY) |
45 | private UUID tenantId; | 48 | private UUID tenantId; |
46 | - @Column(name = RULE_NAME_PROPERTY) | 49 | + @Column(name = ModelConstants.RULE_NAME_PROPERTY) |
47 | private String name; | 50 | private String name; |
48 | @Column(name = ModelConstants.RULE_STATE_PROPERTY, codec = ComponentLifecycleStateCodec.class) | 51 | @Column(name = ModelConstants.RULE_STATE_PROPERTY, codec = ComponentLifecycleStateCodec.class) |
49 | private ComponentLifecycleState state; | 52 | private ComponentLifecycleState state; |
50 | - @Column(name = RULE_WEIGHT_PROPERTY) | 53 | + @Column(name = ModelConstants.RULE_WEIGHT_PROPERTY) |
51 | private int weight; | 54 | private int weight; |
52 | - @Column(name = SEARCH_TEXT_PROPERTY) | 55 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
53 | private String searchText; | 56 | private String searchText; |
54 | - @Column(name = RULE_PLUGIN_TOKEN_PROPERTY) | 57 | + @Column(name = ModelConstants.RULE_PLUGIN_TOKEN_PROPERTY) |
55 | private String pluginToken; | 58 | private String pluginToken; |
56 | - @Column(name = RULE_FILTERS, codec = JsonCodec.class) | 59 | + @Column(name = ModelConstants.RULE_FILTERS, codec = JsonCodec.class) |
57 | private JsonNode filters; | 60 | private JsonNode filters; |
58 | - @Column(name = RULE_PROCESSOR, codec = JsonCodec.class) | 61 | + @Column(name = ModelConstants.RULE_PROCESSOR, codec = JsonCodec.class) |
59 | private JsonNode processor; | 62 | private JsonNode processor; |
60 | - @Column(name = RULE_ACTION, codec = JsonCodec.class) | 63 | + @Column(name = ModelConstants.RULE_ACTION, codec = JsonCodec.class) |
61 | private JsonNode action; | 64 | private JsonNode action; |
62 | - @Column(name = ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 65 | + @Column(name = ModelConstants.ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
63 | private JsonNode additionalInfo; | 66 | private JsonNode additionalInfo; |
64 | 67 | ||
65 | public RuleMetaDataEntity() { | 68 | public RuleMetaDataEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/TenantEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/TenantEntity.java
@@ -13,27 +13,14 @@ | @@ -13,27 +13,14 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | ||
17 | - | ||
18 | -import static org.thingsboard.server.dao.model.ModelConstants.ADDRESS2_PROPERTY; | ||
19 | -import static org.thingsboard.server.dao.model.ModelConstants.ADDRESS_PROPERTY; | ||
20 | -import static org.thingsboard.server.dao.model.ModelConstants.CITY_PROPERTY; | ||
21 | -import static org.thingsboard.server.dao.model.ModelConstants.COUNTRY_PROPERTY; | ||
22 | -import static org.thingsboard.server.dao.model.ModelConstants.EMAIL_PROPERTY; | ||
23 | -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | ||
24 | -import static org.thingsboard.server.dao.model.ModelConstants.PHONE_PROPERTY; | ||
25 | -import static org.thingsboard.server.dao.model.ModelConstants.STATE_PROPERTY; | ||
26 | -import static org.thingsboard.server.dao.model.ModelConstants.TENANT_ADDITIONAL_INFO_PROPERTY; | ||
27 | -import static org.thingsboard.server.dao.model.ModelConstants.TENANT_COLUMN_FAMILY_NAME; | ||
28 | -import static org.thingsboard.server.dao.model.ModelConstants.TENANT_REGION_PROPERTY; | ||
29 | -import static org.thingsboard.server.dao.model.ModelConstants.TENANT_TITLE_PROPERTY; | ||
30 | -import static org.thingsboard.server.dao.model.ModelConstants.ZIP_PROPERTY; | ||
31 | -import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY; | 16 | +package org.thingsboard.server.dao.model.nosql; |
32 | 17 | ||
33 | import java.util.UUID; | 18 | import java.util.UUID; |
34 | 19 | ||
35 | import org.thingsboard.server.common.data.Tenant; | 20 | import org.thingsboard.server.common.data.Tenant; |
36 | import org.thingsboard.server.common.data.id.TenantId; | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
23 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
37 | import org.thingsboard.server.dao.model.type.JsonCodec; | 24 | import org.thingsboard.server.dao.model.type.JsonCodec; |
38 | 25 | ||
39 | import com.datastax.driver.core.utils.UUIDs; | 26 | import com.datastax.driver.core.utils.UUIDs; |
@@ -43,50 +30,50 @@ import com.datastax.driver.mapping.annotations.Table; | @@ -43,50 +30,50 @@ import com.datastax.driver.mapping.annotations.Table; | ||
43 | import com.datastax.driver.mapping.annotations.Transient; | 30 | import com.datastax.driver.mapping.annotations.Transient; |
44 | import com.fasterxml.jackson.databind.JsonNode; | 31 | import com.fasterxml.jackson.databind.JsonNode; |
45 | 32 | ||
46 | -@Table(name = TENANT_COLUMN_FAMILY_NAME) | 33 | +@Table(name = ModelConstants.TENANT_COLUMN_FAMILY_NAME) |
47 | public final class TenantEntity implements SearchTextEntity<Tenant> { | 34 | public final class TenantEntity implements SearchTextEntity<Tenant> { |
48 | 35 | ||
49 | @Transient | 36 | @Transient |
50 | private static final long serialVersionUID = -6198635547142409206L; | 37 | private static final long serialVersionUID = -6198635547142409206L; |
51 | 38 | ||
52 | @PartitionKey(value = 0) | 39 | @PartitionKey(value = 0) |
53 | - @Column(name = ID_PROPERTY) | 40 | + @Column(name = ModelConstants.ID_PROPERTY) |
54 | private UUID id; | 41 | private UUID id; |
55 | 42 | ||
56 | - @Column(name = TENANT_TITLE_PROPERTY) | 43 | + @Column(name = ModelConstants.TENANT_TITLE_PROPERTY) |
57 | private String title; | 44 | private String title; |
58 | 45 | ||
59 | - @Column(name = SEARCH_TEXT_PROPERTY) | 46 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
60 | private String searchText; | 47 | private String searchText; |
61 | 48 | ||
62 | - @Column(name = TENANT_REGION_PROPERTY) | 49 | + @Column(name = ModelConstants.TENANT_REGION_PROPERTY) |
63 | private String region; | 50 | private String region; |
64 | 51 | ||
65 | - @Column(name = COUNTRY_PROPERTY) | 52 | + @Column(name = ModelConstants.COUNTRY_PROPERTY) |
66 | private String country; | 53 | private String country; |
67 | 54 | ||
68 | - @Column(name = STATE_PROPERTY) | 55 | + @Column(name = ModelConstants.STATE_PROPERTY) |
69 | private String state; | 56 | private String state; |
70 | 57 | ||
71 | - @Column(name = CITY_PROPERTY) | 58 | + @Column(name = ModelConstants.CITY_PROPERTY) |
72 | private String city; | 59 | private String city; |
73 | 60 | ||
74 | - @Column(name = ADDRESS_PROPERTY) | 61 | + @Column(name = ModelConstants.ADDRESS_PROPERTY) |
75 | private String address; | 62 | private String address; |
76 | 63 | ||
77 | - @Column(name = ADDRESS2_PROPERTY) | 64 | + @Column(name = ModelConstants.ADDRESS2_PROPERTY) |
78 | private String address2; | 65 | private String address2; |
79 | 66 | ||
80 | - @Column(name = ZIP_PROPERTY) | 67 | + @Column(name = ModelConstants.ZIP_PROPERTY) |
81 | private String zip; | 68 | private String zip; |
82 | 69 | ||
83 | - @Column(name = PHONE_PROPERTY) | 70 | + @Column(name = ModelConstants.PHONE_PROPERTY) |
84 | private String phone; | 71 | private String phone; |
85 | 72 | ||
86 | - @Column(name = EMAIL_PROPERTY) | 73 | + @Column(name = ModelConstants.EMAIL_PROPERTY) |
87 | private String email; | 74 | private String email; |
88 | 75 | ||
89 | - @Column(name = TENANT_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 76 | + @Column(name = ModelConstants.TENANT_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
90 | private JsonNode additionalInfo; | 77 | private JsonNode additionalInfo; |
91 | 78 | ||
92 | public TenantEntity() { | 79 | public TenantEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/UserCredentialsEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/UserCredentialsEntity.java
@@ -13,15 +13,7 @@ | @@ -13,15 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | ||
17 | - | ||
18 | -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | ||
19 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY; | ||
20 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME; | ||
21 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_PASSWORD_PROPERTY; | ||
22 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_USER_ID_PROPERTY; | ||
23 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_ENABLED_PROPERTY; | ||
24 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CREDENTIALS_RESET_TOKEN_PROPERTY; | 16 | +package org.thingsboard.server.dao.model.nosql; |
25 | 17 | ||
26 | import java.util.UUID; | 18 | import java.util.UUID; |
27 | 19 | ||
@@ -34,30 +26,32 @@ import com.datastax.driver.mapping.annotations.Column; | @@ -34,30 +26,32 @@ import com.datastax.driver.mapping.annotations.Column; | ||
34 | import com.datastax.driver.mapping.annotations.PartitionKey; | 26 | import com.datastax.driver.mapping.annotations.PartitionKey; |
35 | import com.datastax.driver.mapping.annotations.Table; | 27 | import com.datastax.driver.mapping.annotations.Table; |
36 | import com.datastax.driver.mapping.annotations.Transient; | 28 | import com.datastax.driver.mapping.annotations.Transient; |
29 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
30 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
37 | 31 | ||
38 | -@Table(name = USER_CREDENTIALS_COLUMN_FAMILY_NAME) | 32 | +@Table(name = ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME) |
39 | public final class UserCredentialsEntity implements BaseEntity<UserCredentials> { | 33 | public final class UserCredentialsEntity implements BaseEntity<UserCredentials> { |
40 | 34 | ||
41 | @Transient | 35 | @Transient |
42 | private static final long serialVersionUID = 1348221414123438374L; | 36 | private static final long serialVersionUID = 1348221414123438374L; |
43 | 37 | ||
44 | @PartitionKey(value = 0) | 38 | @PartitionKey(value = 0) |
45 | - @Column(name = ID_PROPERTY) | 39 | + @Column(name = ModelConstants.ID_PROPERTY) |
46 | private UUID id; | 40 | private UUID id; |
47 | 41 | ||
48 | - @Column(name = USER_CREDENTIALS_USER_ID_PROPERTY) | 42 | + @Column(name = ModelConstants.USER_CREDENTIALS_USER_ID_PROPERTY) |
49 | private UUID userId; | 43 | private UUID userId; |
50 | 44 | ||
51 | - @Column(name = USER_CREDENTIALS_ENABLED_PROPERTY) | 45 | + @Column(name = ModelConstants.USER_CREDENTIALS_ENABLED_PROPERTY) |
52 | private boolean enabled; | 46 | private boolean enabled; |
53 | 47 | ||
54 | - @Column(name = USER_CREDENTIALS_PASSWORD_PROPERTY) | 48 | + @Column(name = ModelConstants.USER_CREDENTIALS_PASSWORD_PROPERTY) |
55 | private String password; | 49 | private String password; |
56 | 50 | ||
57 | - @Column(name = USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY) | 51 | + @Column(name = ModelConstants.USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY) |
58 | private String activateToken; | 52 | private String activateToken; |
59 | 53 | ||
60 | - @Column(name = USER_CREDENTIALS_RESET_TOKEN_PROPERTY) | 54 | + @Column(name = ModelConstants.USER_CREDENTIALS_RESET_TOKEN_PROPERTY) |
61 | private String resetToken; | 55 | private String resetToken; |
62 | 56 | ||
63 | public UserCredentialsEntity() { | 57 | public UserCredentialsEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/UserEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/UserEntity.java
@@ -13,18 +13,7 @@ | @@ -13,18 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | ||
17 | - | ||
18 | -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | ||
19 | -import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY; | ||
20 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_ADDITIONAL_INFO_PROPERTY; | ||
21 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_AUTHORITY_PROPERTY; | ||
22 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_COLUMN_FAMILY_NAME; | ||
23 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_CUSTOMER_ID_PROPERTY; | ||
24 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_EMAIL_PROPERTY; | ||
25 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_FIRST_NAME_PROPERTY; | ||
26 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_LAST_NAME_PROPERTY; | ||
27 | -import static org.thingsboard.server.dao.model.ModelConstants.USER_TENANT_ID_PROPERTY; | 16 | +package org.thingsboard.server.dao.model.nosql; |
28 | 17 | ||
29 | import java.util.UUID; | 18 | import java.util.UUID; |
30 | 19 | ||
@@ -33,6 +22,8 @@ import org.thingsboard.server.common.data.id.CustomerId; | @@ -33,6 +22,8 @@ import org.thingsboard.server.common.data.id.CustomerId; | ||
33 | import org.thingsboard.server.common.data.id.TenantId; | 22 | import org.thingsboard.server.common.data.id.TenantId; |
34 | import org.thingsboard.server.common.data.id.UserId; | 23 | import org.thingsboard.server.common.data.id.UserId; |
35 | import org.thingsboard.server.common.data.security.Authority; | 24 | import org.thingsboard.server.common.data.security.Authority; |
25 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
26 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
36 | import org.thingsboard.server.dao.model.type.AuthorityCodec; | 27 | import org.thingsboard.server.dao.model.type.AuthorityCodec; |
37 | import org.thingsboard.server.dao.model.type.JsonCodec; | 28 | import org.thingsboard.server.dao.model.type.JsonCodec; |
38 | 29 | ||
@@ -43,41 +34,41 @@ import com.datastax.driver.mapping.annotations.Table; | @@ -43,41 +34,41 @@ import com.datastax.driver.mapping.annotations.Table; | ||
43 | import com.datastax.driver.mapping.annotations.Transient; | 34 | import com.datastax.driver.mapping.annotations.Transient; |
44 | import com.fasterxml.jackson.databind.JsonNode; | 35 | import com.fasterxml.jackson.databind.JsonNode; |
45 | 36 | ||
46 | -@Table(name = USER_COLUMN_FAMILY_NAME) | 37 | +@Table(name = ModelConstants.USER_COLUMN_FAMILY_NAME) |
47 | public final class UserEntity implements SearchTextEntity<User> { | 38 | public final class UserEntity implements SearchTextEntity<User> { |
48 | 39 | ||
49 | @Transient | 40 | @Transient |
50 | private static final long serialVersionUID = -7740338274987723489L; | 41 | private static final long serialVersionUID = -7740338274987723489L; |
51 | 42 | ||
52 | @PartitionKey(value = 0) | 43 | @PartitionKey(value = 0) |
53 | - @Column(name = ID_PROPERTY) | 44 | + @Column(name = ModelConstants.ID_PROPERTY) |
54 | private UUID id; | 45 | private UUID id; |
55 | 46 | ||
56 | @PartitionKey(value = 1) | 47 | @PartitionKey(value = 1) |
57 | - @Column(name = USER_TENANT_ID_PROPERTY) | 48 | + @Column(name = ModelConstants.USER_TENANT_ID_PROPERTY) |
58 | private UUID tenantId; | 49 | private UUID tenantId; |
59 | 50 | ||
60 | @PartitionKey(value = 2) | 51 | @PartitionKey(value = 2) |
61 | - @Column(name = USER_CUSTOMER_ID_PROPERTY) | 52 | + @Column(name = ModelConstants.USER_CUSTOMER_ID_PROPERTY) |
62 | private UUID customerId; | 53 | private UUID customerId; |
63 | 54 | ||
64 | @PartitionKey(value = 3) | 55 | @PartitionKey(value = 3) |
65 | - @Column(name = USER_AUTHORITY_PROPERTY, codec = AuthorityCodec.class) | 56 | + @Column(name = ModelConstants.USER_AUTHORITY_PROPERTY, codec = AuthorityCodec.class) |
66 | private Authority authority; | 57 | private Authority authority; |
67 | 58 | ||
68 | - @Column(name = USER_EMAIL_PROPERTY) | 59 | + @Column(name = ModelConstants.USER_EMAIL_PROPERTY) |
69 | private String email; | 60 | private String email; |
70 | 61 | ||
71 | - @Column(name = SEARCH_TEXT_PROPERTY) | 62 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
72 | private String searchText; | 63 | private String searchText; |
73 | 64 | ||
74 | - @Column(name = USER_FIRST_NAME_PROPERTY) | 65 | + @Column(name = ModelConstants.USER_FIRST_NAME_PROPERTY) |
75 | private String firstName; | 66 | private String firstName; |
76 | 67 | ||
77 | - @Column(name = USER_LAST_NAME_PROPERTY) | 68 | + @Column(name = ModelConstants.USER_LAST_NAME_PROPERTY) |
78 | private String lastName; | 69 | private String lastName; |
79 | 70 | ||
80 | - @Column(name = USER_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) | 71 | + @Column(name = ModelConstants.USER_ADDITIONAL_INFO_PROPERTY, codec = JsonCodec.class) |
81 | private JsonNode additionalInfo; | 72 | private JsonNode additionalInfo; |
82 | 73 | ||
83 | public UserEntity() { | 74 | public UserEntity() { |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/WidgetTypeEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/WidgetTypeEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | import com.datastax.driver.core.utils.UUIDs; | 18 | import com.datastax.driver.core.utils.UUIDs; |
19 | import com.datastax.driver.mapping.annotations.Column; | 19 | import com.datastax.driver.mapping.annotations.Column; |
@@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.JsonNode; | @@ -24,6 +24,8 @@ import com.fasterxml.jackson.databind.JsonNode; | ||
24 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | import org.thingsboard.server.common.data.id.WidgetTypeId; | 25 | import org.thingsboard.server.common.data.id.WidgetTypeId; |
26 | import org.thingsboard.server.common.data.widget.WidgetType; | 26 | import org.thingsboard.server.common.data.widget.WidgetType; |
27 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
27 | import org.thingsboard.server.dao.model.type.JsonCodec; | 29 | import org.thingsboard.server.dao.model.type.JsonCodec; |
28 | 30 | ||
29 | import java.util.UUID; | 31 | import java.util.UUID; |
dao/src/main/java/org/thingsboard/server/dao/model/nosql/WidgetsBundleEntity.java
renamed from
dao/src/main/java/org/thingsboard/server/dao/model/WidgetsBundleEntity.java
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.thingsboard.server.dao.model; | 16 | +package org.thingsboard.server.dao.model.nosql; |
17 | 17 | ||
18 | 18 | ||
19 | import com.datastax.driver.core.utils.UUIDs; | 19 | import com.datastax.driver.core.utils.UUIDs; |
@@ -24,6 +24,8 @@ import com.datastax.driver.mapping.annotations.Transient; | @@ -24,6 +24,8 @@ import com.datastax.driver.mapping.annotations.Transient; | ||
24 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | import org.thingsboard.server.common.data.id.WidgetsBundleId; | 25 | import org.thingsboard.server.common.data.id.WidgetsBundleId; |
26 | import org.thingsboard.server.common.data.widget.WidgetsBundle; | 26 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
27 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
28 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
27 | 29 | ||
28 | import java.nio.ByteBuffer; | 30 | import java.nio.ByteBuffer; |
29 | import java.util.UUID; | 31 | import java.util.UUID; |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.AdminSettings; | ||
26 | +import org.thingsboard.server.common.data.id.AdminSettingsId; | ||
27 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
28 | + | ||
29 | +import java.util.UUID; | ||
30 | + | ||
31 | +import static org.thingsboard.server.dao.model.ModelConstants.*; | ||
32 | + | ||
33 | +@Entity | ||
34 | +@Table(name = ADMIN_SETTINGS_COLUMN_FAMILY_NAME) | ||
35 | +public final class AdminSettingsEntity implements BaseEntity<AdminSettings> { | ||
36 | + | ||
37 | + @Transient | ||
38 | + private static final long serialVersionUID = 842759712850362147L; | ||
39 | + | ||
40 | + @Id | ||
41 | + @Column(name = ID_PROPERTY) | ||
42 | + private UUID id; | ||
43 | + | ||
44 | + @Column(name = ADMIN_SETTINGS_KEY_PROPERTY) | ||
45 | + private String key; | ||
46 | + | ||
47 | + @Column(name = ADMIN_SETTINGS_JSON_VALUE_PROPERTY) | ||
48 | + private JsonNode jsonValue; | ||
49 | + | ||
50 | + public AdminSettingsEntity() { | ||
51 | + super(); | ||
52 | + } | ||
53 | + | ||
54 | + public AdminSettingsEntity(AdminSettings adminSettings) { | ||
55 | + if (adminSettings.getId() != null) { | ||
56 | + this.id = adminSettings.getId().getId(); | ||
57 | + } | ||
58 | + this.key = adminSettings.getKey(); | ||
59 | + this.jsonValue = adminSettings.getJsonValue(); | ||
60 | + } | ||
61 | + | ||
62 | + public UUID getId() { | ||
63 | + return id; | ||
64 | + } | ||
65 | + | ||
66 | + public void setId(UUID id) { | ||
67 | + this.id = id; | ||
68 | + } | ||
69 | + | ||
70 | + public String getKey() { | ||
71 | + return key; | ||
72 | + } | ||
73 | + | ||
74 | + public void setKey(String key) { | ||
75 | + this.key = key; | ||
76 | + } | ||
77 | + | ||
78 | + public JsonNode getJsonValue() { | ||
79 | + return jsonValue; | ||
80 | + } | ||
81 | + | ||
82 | + public void setJsonValue(JsonNode jsonValue) { | ||
83 | + this.jsonValue = jsonValue; | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public int hashCode() { | ||
88 | + final int prime = 31; | ||
89 | + int result = 1; | ||
90 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
91 | + result = prime * result + ((jsonValue == null) ? 0 : jsonValue.hashCode()); | ||
92 | + result = prime * result + ((key == null) ? 0 : key.hashCode()); | ||
93 | + return result; | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public boolean equals(Object obj) { | ||
98 | + if (this == obj) | ||
99 | + return true; | ||
100 | + if (obj == null) | ||
101 | + return false; | ||
102 | + if (getClass() != obj.getClass()) | ||
103 | + return false; | ||
104 | + AdminSettingsEntity other = (AdminSettingsEntity) obj; | ||
105 | + if (id == null) { | ||
106 | + if (other.id != null) | ||
107 | + return false; | ||
108 | + } else if (!id.equals(other.id)) | ||
109 | + return false; | ||
110 | + if (jsonValue == null) { | ||
111 | + if (other.jsonValue != null) | ||
112 | + return false; | ||
113 | + } else if (!jsonValue.equals(other.jsonValue)) | ||
114 | + return false; | ||
115 | + if (key == null) { | ||
116 | + if (other.key != null) | ||
117 | + return false; | ||
118 | + } else if (!key.equals(other.key)) | ||
119 | + return false; | ||
120 | + return true; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public String toString() { | ||
125 | + StringBuilder builder = new StringBuilder(); | ||
126 | + builder.append("AdminSettingsEntity [id="); | ||
127 | + builder.append(id); | ||
128 | + builder.append(", key="); | ||
129 | + builder.append(key); | ||
130 | + builder.append(", jsonValue="); | ||
131 | + builder.append(jsonValue); | ||
132 | + builder.append("]"); | ||
133 | + return builder.toString(); | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public AdminSettings toData() { | ||
138 | + AdminSettings adminSettings = new AdminSettings(new AdminSettingsId(id)); | ||
139 | + adminSettings.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
140 | + adminSettings.setKey(key); | ||
141 | + adminSettings.setJsonValue(jsonValue); | ||
142 | + return adminSettings; | ||
143 | + } | ||
144 | + | ||
145 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import javax.persistence.Column; | ||
19 | +import javax.persistence.Entity; | ||
20 | +import javax.persistence.Id; | ||
21 | +import javax.persistence.Table; | ||
22 | +import javax.persistence.Transient; | ||
23 | +import com.fasterxml.jackson.databind.JsonNode; | ||
24 | +import org.thingsboard.server.common.data.id.ComponentDescriptorId; | ||
25 | +import org.thingsboard.server.common.data.plugin.ComponentDescriptor; | ||
26 | +import org.thingsboard.server.common.data.plugin.ComponentScope; | ||
27 | +import org.thingsboard.server.common.data.plugin.ComponentType; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | + | ||
31 | +import java.util.UUID; | ||
32 | + | ||
33 | +@Entity | ||
34 | +@Table(name = ModelConstants.COMPONENT_DESCRIPTOR_COLUMN_FAMILY_NAME) | ||
35 | +public class ComponentDescriptorEntity implements SearchTextEntity<ComponentDescriptor> { | ||
36 | + | ||
37 | + @Transient | ||
38 | + private static final long serialVersionUID = 253590350877992402L; | ||
39 | + | ||
40 | + @Id | ||
41 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
42 | + private UUID id; | ||
43 | + | ||
44 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_TYPE_PROPERTY) | ||
45 | + private ComponentType type; | ||
46 | + | ||
47 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_SCOPE_PROPERTY) | ||
48 | + private ComponentScope scope; | ||
49 | + | ||
50 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_NAME_PROPERTY) | ||
51 | + private String name; | ||
52 | + | ||
53 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_CLASS_PROPERTY) | ||
54 | + private String clazz; | ||
55 | + | ||
56 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_CONFIGURATION_DESCRIPTOR_PROPERTY) | ||
57 | + private JsonNode configurationDescriptor; | ||
58 | + | ||
59 | + @Column(name = ModelConstants.COMPONENT_DESCRIPTOR_ACTIONS_PROPERTY) | ||
60 | + private String actions; | ||
61 | + | ||
62 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
63 | + private String searchText; | ||
64 | + | ||
65 | + public ComponentDescriptorEntity() { | ||
66 | + } | ||
67 | + | ||
68 | + public ComponentDescriptorEntity(ComponentDescriptor component) { | ||
69 | + if (component.getId() != null) { | ||
70 | + this.id = component.getId().getId(); | ||
71 | + } | ||
72 | + this.actions = component.getActions(); | ||
73 | + this.type = component.getType(); | ||
74 | + this.scope = component.getScope(); | ||
75 | + this.name = component.getName(); | ||
76 | + this.clazz = component.getClazz(); | ||
77 | + this.configurationDescriptor = component.getConfigurationDescriptor(); | ||
78 | + this.searchText = component.getName(); | ||
79 | + } | ||
80 | + | ||
81 | + @Override | ||
82 | + public ComponentDescriptor toData() { | ||
83 | + ComponentDescriptor data = new ComponentDescriptor(new ComponentDescriptorId(id)); | ||
84 | + data.setType(type); | ||
85 | + data.setScope(scope); | ||
86 | + data.setName(this.getName()); | ||
87 | + data.setClazz(this.getClazz()); | ||
88 | + data.setActions(this.getActions()); | ||
89 | + data.setConfigurationDescriptor(this.getConfigurationDescriptor()); | ||
90 | + return data; | ||
91 | + } | ||
92 | + | ||
93 | + @Override | ||
94 | + public UUID getId() { | ||
95 | + return id; | ||
96 | + } | ||
97 | + | ||
98 | + @Override | ||
99 | + public void setId(UUID id) { | ||
100 | + this.id = id; | ||
101 | + } | ||
102 | + | ||
103 | + public String getActions() { | ||
104 | + return actions; | ||
105 | + } | ||
106 | + | ||
107 | + public void setActions(String actions) { | ||
108 | + this.actions = actions; | ||
109 | + } | ||
110 | + | ||
111 | + public ComponentType getType() { | ||
112 | + return type; | ||
113 | + } | ||
114 | + | ||
115 | + public void setType(ComponentType type) { | ||
116 | + this.type = type; | ||
117 | + } | ||
118 | + | ||
119 | + public ComponentScope getScope() { | ||
120 | + return scope; | ||
121 | + } | ||
122 | + | ||
123 | + public void setScope(ComponentScope scope) { | ||
124 | + this.scope = scope; | ||
125 | + } | ||
126 | + | ||
127 | + public String getName() { | ||
128 | + return name; | ||
129 | + } | ||
130 | + | ||
131 | + public void setName(String name) { | ||
132 | + this.name = name; | ||
133 | + } | ||
134 | + | ||
135 | + public String getClazz() { | ||
136 | + return clazz; | ||
137 | + } | ||
138 | + | ||
139 | + public void setClazz(String clazz) { | ||
140 | + this.clazz = clazz; | ||
141 | + } | ||
142 | + | ||
143 | + public JsonNode getConfigurationDescriptor() { | ||
144 | + return configurationDescriptor; | ||
145 | + } | ||
146 | + | ||
147 | + public void setConfigurationDescriptor(JsonNode configurationDescriptor) { | ||
148 | + this.configurationDescriptor = configurationDescriptor; | ||
149 | + } | ||
150 | + | ||
151 | + public String getSearchText() { | ||
152 | + return searchText; | ||
153 | + } | ||
154 | + | ||
155 | + @Override | ||
156 | + public void setSearchText(String searchText) { | ||
157 | + this.searchText = searchText; | ||
158 | + } | ||
159 | + | ||
160 | + @Override | ||
161 | + public String getSearchTextSource() { | ||
162 | + return searchText; | ||
163 | + } | ||
164 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.Customer; | ||
26 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
27 | +import org.thingsboard.server.common.data.id.TenantId; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | + | ||
31 | +import java.util.UUID; | ||
32 | + | ||
33 | +@Entity | ||
34 | +@Table(name = ModelConstants.CUSTOMER_COLUMN_FAMILY_NAME) | ||
35 | +public final class CustomerEntity implements SearchTextEntity<Customer> { | ||
36 | + | ||
37 | + @Transient | ||
38 | + private static final long serialVersionUID = 8951342124082981556L; | ||
39 | + | ||
40 | + @Id | ||
41 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
42 | + private UUID id; | ||
43 | + | ||
44 | + @Column(name = ModelConstants.CUSTOMER_TENANT_ID_PROPERTY) | ||
45 | + private UUID tenantId; | ||
46 | + | ||
47 | + @Column(name = ModelConstants.CUSTOMER_TITLE_PROPERTY) | ||
48 | + private String title; | ||
49 | + | ||
50 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
51 | + private String searchText; | ||
52 | + | ||
53 | + @Column(name = ModelConstants.COUNTRY_PROPERTY) | ||
54 | + private String country; | ||
55 | + | ||
56 | + @Column(name = ModelConstants.STATE_PROPERTY) | ||
57 | + private String state; | ||
58 | + | ||
59 | + @Column(name = ModelConstants.CITY_PROPERTY) | ||
60 | + private String city; | ||
61 | + | ||
62 | + @Column(name = ModelConstants.ADDRESS_PROPERTY) | ||
63 | + private String address; | ||
64 | + | ||
65 | + @Column(name = ModelConstants.ADDRESS2_PROPERTY) | ||
66 | + private String address2; | ||
67 | + | ||
68 | + @Column(name = ModelConstants.ZIP_PROPERTY) | ||
69 | + private String zip; | ||
70 | + | ||
71 | + @Column(name = ModelConstants.PHONE_PROPERTY) | ||
72 | + private String phone; | ||
73 | + | ||
74 | + @Column(name = ModelConstants.EMAIL_PROPERTY) | ||
75 | + private String email; | ||
76 | + | ||
77 | + @Column(name = ModelConstants.CUSTOMER_ADDITIONAL_INFO_PROPERTY) | ||
78 | + private JsonNode additionalInfo; | ||
79 | + | ||
80 | + public CustomerEntity() { | ||
81 | + super(); | ||
82 | + } | ||
83 | + | ||
84 | + public CustomerEntity(Customer customer) { | ||
85 | + if (customer.getId() != null) { | ||
86 | + this.id = customer.getId().getId(); | ||
87 | + } | ||
88 | + this.tenantId = customer.getTenantId().getId(); | ||
89 | + this.title = customer.getTitle(); | ||
90 | + this.country = customer.getCountry(); | ||
91 | + this.state = customer.getState(); | ||
92 | + this.city = customer.getCity(); | ||
93 | + this.address = customer.getAddress(); | ||
94 | + this.address2 = customer.getAddress2(); | ||
95 | + this.zip = customer.getZip(); | ||
96 | + this.phone = customer.getPhone(); | ||
97 | + this.email = customer.getEmail(); | ||
98 | + this.additionalInfo = customer.getAdditionalInfo(); | ||
99 | + } | ||
100 | + | ||
101 | + public UUID getId() { | ||
102 | + return id; | ||
103 | + } | ||
104 | + | ||
105 | + public void setId(UUID id) { | ||
106 | + this.id = id; | ||
107 | + } | ||
108 | + | ||
109 | + public UUID getTenantId() { | ||
110 | + return tenantId; | ||
111 | + } | ||
112 | + | ||
113 | + public void setTenantId(UUID tenantId) { | ||
114 | + this.tenantId = tenantId; | ||
115 | + } | ||
116 | + | ||
117 | + public String getTitle() { | ||
118 | + return title; | ||
119 | + } | ||
120 | + | ||
121 | + public void setTitle(String title) { | ||
122 | + this.title = title; | ||
123 | + } | ||
124 | + | ||
125 | + public String getCountry() { | ||
126 | + return country; | ||
127 | + } | ||
128 | + | ||
129 | + public void setCountry(String country) { | ||
130 | + this.country = country; | ||
131 | + } | ||
132 | + | ||
133 | + public String getState() { | ||
134 | + return state; | ||
135 | + } | ||
136 | + | ||
137 | + public void setState(String state) { | ||
138 | + this.state = state; | ||
139 | + } | ||
140 | + | ||
141 | + public String getCity() { | ||
142 | + return city; | ||
143 | + } | ||
144 | + | ||
145 | + public void setCity(String city) { | ||
146 | + this.city = city; | ||
147 | + } | ||
148 | + | ||
149 | + public String getAddress() { | ||
150 | + return address; | ||
151 | + } | ||
152 | + | ||
153 | + public void setAddress(String address) { | ||
154 | + this.address = address; | ||
155 | + } | ||
156 | + | ||
157 | + public String getAddress2() { | ||
158 | + return address2; | ||
159 | + } | ||
160 | + | ||
161 | + public void setAddress2(String address2) { | ||
162 | + this.address2 = address2; | ||
163 | + } | ||
164 | + | ||
165 | + public String getZip() { | ||
166 | + return zip; | ||
167 | + } | ||
168 | + | ||
169 | + public void setZip(String zip) { | ||
170 | + this.zip = zip; | ||
171 | + } | ||
172 | + | ||
173 | + public String getPhone() { | ||
174 | + return phone; | ||
175 | + } | ||
176 | + | ||
177 | + public void setPhone(String phone) { | ||
178 | + this.phone = phone; | ||
179 | + } | ||
180 | + | ||
181 | + public String getEmail() { | ||
182 | + return email; | ||
183 | + } | ||
184 | + | ||
185 | + public void setEmail(String email) { | ||
186 | + this.email = email; | ||
187 | + } | ||
188 | + | ||
189 | + public JsonNode getAdditionalInfo() { | ||
190 | + return additionalInfo; | ||
191 | + } | ||
192 | + | ||
193 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
194 | + this.additionalInfo = additionalInfo; | ||
195 | + } | ||
196 | + | ||
197 | + @Override | ||
198 | + public String getSearchTextSource() { | ||
199 | + return title; | ||
200 | + } | ||
201 | + | ||
202 | + @Override | ||
203 | + public void setSearchText(String searchText) { | ||
204 | + this.searchText = searchText; | ||
205 | + } | ||
206 | + | ||
207 | + public String getSearchText() { | ||
208 | + return searchText; | ||
209 | + } | ||
210 | + | ||
211 | + @Override | ||
212 | + public int hashCode() { | ||
213 | + final int prime = 31; | ||
214 | + int result = 1; | ||
215 | + result = prime * result + ((additionalInfo == null) ? 0 : additionalInfo.hashCode()); | ||
216 | + result = prime * result + ((address == null) ? 0 : address.hashCode()); | ||
217 | + result = prime * result + ((address2 == null) ? 0 : address2.hashCode()); | ||
218 | + result = prime * result + ((city == null) ? 0 : city.hashCode()); | ||
219 | + result = prime * result + ((country == null) ? 0 : country.hashCode()); | ||
220 | + result = prime * result + ((email == null) ? 0 : email.hashCode()); | ||
221 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
222 | + result = prime * result + ((phone == null) ? 0 : phone.hashCode()); | ||
223 | + result = prime * result + ((state == null) ? 0 : state.hashCode()); | ||
224 | + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); | ||
225 | + result = prime * result + ((title == null) ? 0 : title.hashCode()); | ||
226 | + result = prime * result + ((zip == null) ? 0 : zip.hashCode()); | ||
227 | + return result; | ||
228 | + } | ||
229 | + | ||
230 | + @Override | ||
231 | + public boolean equals(Object obj) { | ||
232 | + if (this == obj) | ||
233 | + return true; | ||
234 | + if (obj == null) | ||
235 | + return false; | ||
236 | + if (getClass() != obj.getClass()) | ||
237 | + return false; | ||
238 | + CustomerEntity other = (CustomerEntity) obj; | ||
239 | + if (additionalInfo == null) { | ||
240 | + if (other.additionalInfo != null) | ||
241 | + return false; | ||
242 | + } else if (!additionalInfo.equals(other.additionalInfo)) | ||
243 | + return false; | ||
244 | + if (address == null) { | ||
245 | + if (other.address != null) | ||
246 | + return false; | ||
247 | + } else if (!address.equals(other.address)) | ||
248 | + return false; | ||
249 | + if (address2 == null) { | ||
250 | + if (other.address2 != null) | ||
251 | + return false; | ||
252 | + } else if (!address2.equals(other.address2)) | ||
253 | + return false; | ||
254 | + if (city == null) { | ||
255 | + if (other.city != null) | ||
256 | + return false; | ||
257 | + } else if (!city.equals(other.city)) | ||
258 | + return false; | ||
259 | + if (country == null) { | ||
260 | + if (other.country != null) | ||
261 | + return false; | ||
262 | + } else if (!country.equals(other.country)) | ||
263 | + return false; | ||
264 | + if (email == null) { | ||
265 | + if (other.email != null) | ||
266 | + return false; | ||
267 | + } else if (!email.equals(other.email)) | ||
268 | + return false; | ||
269 | + if (id == null) { | ||
270 | + if (other.id != null) | ||
271 | + return false; | ||
272 | + } else if (!id.equals(other.id)) | ||
273 | + return false; | ||
274 | + if (phone == null) { | ||
275 | + if (other.phone != null) | ||
276 | + return false; | ||
277 | + } else if (!phone.equals(other.phone)) | ||
278 | + return false; | ||
279 | + if (state == null) { | ||
280 | + if (other.state != null) | ||
281 | + return false; | ||
282 | + } else if (!state.equals(other.state)) | ||
283 | + return false; | ||
284 | + if (tenantId == null) { | ||
285 | + if (other.tenantId != null) | ||
286 | + return false; | ||
287 | + } else if (!tenantId.equals(other.tenantId)) | ||
288 | + return false; | ||
289 | + if (title == null) { | ||
290 | + if (other.title != null) | ||
291 | + return false; | ||
292 | + } else if (!title.equals(other.title)) | ||
293 | + return false; | ||
294 | + if (zip == null) { | ||
295 | + if (other.zip != null) | ||
296 | + return false; | ||
297 | + } else if (!zip.equals(other.zip)) | ||
298 | + return false; | ||
299 | + return true; | ||
300 | + } | ||
301 | + | ||
302 | + @Override | ||
303 | + public String toString() { | ||
304 | + StringBuilder builder = new StringBuilder(); | ||
305 | + builder.append("CustomerEntity [id="); | ||
306 | + builder.append(id); | ||
307 | + builder.append(", tenantId="); | ||
308 | + builder.append(tenantId); | ||
309 | + builder.append(", title="); | ||
310 | + builder.append(title); | ||
311 | + builder.append(", country="); | ||
312 | + builder.append(country); | ||
313 | + builder.append(", state="); | ||
314 | + builder.append(state); | ||
315 | + builder.append(", city="); | ||
316 | + builder.append(city); | ||
317 | + builder.append(", address="); | ||
318 | + builder.append(address); | ||
319 | + builder.append(", address2="); | ||
320 | + builder.append(address2); | ||
321 | + builder.append(", zip="); | ||
322 | + builder.append(zip); | ||
323 | + builder.append(", phone="); | ||
324 | + builder.append(phone); | ||
325 | + builder.append(", email="); | ||
326 | + builder.append(email); | ||
327 | + builder.append(", additionalInfo="); | ||
328 | + builder.append(additionalInfo); | ||
329 | + builder.append("]"); | ||
330 | + return builder.toString(); | ||
331 | + } | ||
332 | + | ||
333 | + @Override | ||
334 | + public Customer toData() { | ||
335 | + Customer customer = new Customer(new CustomerId(id)); | ||
336 | + customer.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
337 | + customer.setTenantId(new TenantId(tenantId)); | ||
338 | + customer.setTitle(title); | ||
339 | + customer.setCountry(country); | ||
340 | + customer.setState(state); | ||
341 | + customer.setCity(city); | ||
342 | + customer.setAddress(address); | ||
343 | + customer.setAddress2(address2); | ||
344 | + customer.setZip(zip); | ||
345 | + customer.setPhone(phone); | ||
346 | + customer.setEmail(email); | ||
347 | + customer.setAdditionalInfo(additionalInfo); | ||
348 | + return customer; | ||
349 | + } | ||
350 | + | ||
351 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.Dashboard; | ||
26 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
27 | +import org.thingsboard.server.common.data.id.DashboardId; | ||
28 | +import org.thingsboard.server.common.data.id.TenantId; | ||
29 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | + | ||
32 | +import java.util.UUID; | ||
33 | + | ||
34 | +@Entity | ||
35 | +@Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) | ||
36 | +public final class DashboardEntity implements SearchTextEntity<Dashboard> { | ||
37 | + | ||
38 | + @Transient | ||
39 | + private static final long serialVersionUID = -4838084363113078898L; | ||
40 | + | ||
41 | + @Id | ||
42 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
43 | + private UUID id; | ||
44 | + | ||
45 | + @Column(name = ModelConstants.DASHBOARD_TENANT_ID_PROPERTY) | ||
46 | + private UUID tenantId; | ||
47 | + | ||
48 | + @Column(name = ModelConstants.DASHBOARD_CUSTOMER_ID_PROPERTY) | ||
49 | + private UUID customerId; | ||
50 | + | ||
51 | + @Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY) | ||
52 | + private String title; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
55 | + private String searchText; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.DASHBOARD_CONFIGURATION_PROPERTY) | ||
58 | + private JsonNode configuration; | ||
59 | + | ||
60 | + public DashboardEntity() { | ||
61 | + super(); | ||
62 | + } | ||
63 | + | ||
64 | + public DashboardEntity(Dashboard dashboard) { | ||
65 | + if (dashboard.getId() != null) { | ||
66 | + this.id = dashboard.getId().getId(); | ||
67 | + } | ||
68 | + if (dashboard.getTenantId() != null) { | ||
69 | + this.tenantId = dashboard.getTenantId().getId(); | ||
70 | + } | ||
71 | + if (dashboard.getCustomerId() != null) { | ||
72 | + this.customerId = dashboard.getCustomerId().getId(); | ||
73 | + } | ||
74 | + this.title = dashboard.getTitle(); | ||
75 | + this.configuration = dashboard.getConfiguration(); | ||
76 | + } | ||
77 | + | ||
78 | + public UUID getId() { | ||
79 | + return id; | ||
80 | + } | ||
81 | + | ||
82 | + public void setId(UUID id) { | ||
83 | + this.id = id; | ||
84 | + } | ||
85 | + | ||
86 | + public UUID getTenantId() { | ||
87 | + return tenantId; | ||
88 | + } | ||
89 | + | ||
90 | + public void setTenantId(UUID tenantId) { | ||
91 | + this.tenantId = tenantId; | ||
92 | + } | ||
93 | + | ||
94 | + public UUID getCustomerId() { | ||
95 | + return customerId; | ||
96 | + } | ||
97 | + | ||
98 | + public void setCustomerId(UUID customerId) { | ||
99 | + this.customerId = customerId; | ||
100 | + } | ||
101 | + | ||
102 | + public String getTitle() { | ||
103 | + return title; | ||
104 | + } | ||
105 | + | ||
106 | + public void setTitle(String title) { | ||
107 | + this.title = title; | ||
108 | + } | ||
109 | + | ||
110 | + public JsonNode getConfiguration() { | ||
111 | + return configuration; | ||
112 | + } | ||
113 | + | ||
114 | + public void setConfiguration(JsonNode configuration) { | ||
115 | + this.configuration = configuration; | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public String getSearchTextSource() { | ||
120 | + return title; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public void setSearchText(String searchText) { | ||
125 | + this.searchText = searchText; | ||
126 | + } | ||
127 | + | ||
128 | + public String getSearchText() { | ||
129 | + return searchText; | ||
130 | + } | ||
131 | + | ||
132 | + @Override | ||
133 | + public int hashCode() { | ||
134 | + final int prime = 31; | ||
135 | + int result = 1; | ||
136 | + result = prime * result + ((configuration == null) ? 0 : configuration.hashCode()); | ||
137 | + result = prime * result + ((customerId == null) ? 0 : customerId.hashCode()); | ||
138 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
139 | + result = prime * result + ((searchText == null) ? 0 : searchText.hashCode()); | ||
140 | + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); | ||
141 | + result = prime * result + ((title == null) ? 0 : title.hashCode()); | ||
142 | + return result; | ||
143 | + } | ||
144 | + | ||
145 | + @Override | ||
146 | + public boolean equals(Object obj) { | ||
147 | + if (this == obj) | ||
148 | + return true; | ||
149 | + if (obj == null) | ||
150 | + return false; | ||
151 | + if (getClass() != obj.getClass()) | ||
152 | + return false; | ||
153 | + DashboardEntity other = (DashboardEntity) obj; | ||
154 | + if (configuration == null) { | ||
155 | + if (other.configuration != null) | ||
156 | + return false; | ||
157 | + } else if (!configuration.equals(other.configuration)) | ||
158 | + return false; | ||
159 | + if (customerId == null) { | ||
160 | + if (other.customerId != null) | ||
161 | + return false; | ||
162 | + } else if (!customerId.equals(other.customerId)) | ||
163 | + return false; | ||
164 | + if (id == null) { | ||
165 | + if (other.id != null) | ||
166 | + return false; | ||
167 | + } else if (!id.equals(other.id)) | ||
168 | + return false; | ||
169 | + if (searchText == null) { | ||
170 | + if (other.searchText != null) | ||
171 | + return false; | ||
172 | + } else if (!searchText.equals(other.searchText)) | ||
173 | + return false; | ||
174 | + if (tenantId == null) { | ||
175 | + if (other.tenantId != null) | ||
176 | + return false; | ||
177 | + } else if (!tenantId.equals(other.tenantId)) | ||
178 | + return false; | ||
179 | + if (title == null) { | ||
180 | + if (other.title != null) | ||
181 | + return false; | ||
182 | + } else if (!title.equals(other.title)) | ||
183 | + return false; | ||
184 | + return true; | ||
185 | + } | ||
186 | + | ||
187 | + @Override | ||
188 | + public String toString() { | ||
189 | + StringBuilder builder = new StringBuilder(); | ||
190 | + builder.append("DashboardEntity [id="); | ||
191 | + builder.append(id); | ||
192 | + builder.append(", tenantId="); | ||
193 | + builder.append(tenantId); | ||
194 | + builder.append(", customerId="); | ||
195 | + builder.append(customerId); | ||
196 | + builder.append(", title="); | ||
197 | + builder.append(title); | ||
198 | + builder.append(", searchText="); | ||
199 | + builder.append(searchText); | ||
200 | + builder.append(", configuration="); | ||
201 | + builder.append(configuration); | ||
202 | + builder.append("]"); | ||
203 | + return builder.toString(); | ||
204 | + } | ||
205 | + | ||
206 | + @Override | ||
207 | + public Dashboard toData() { | ||
208 | + Dashboard dashboard = new Dashboard(new DashboardId(id)); | ||
209 | + dashboard.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
210 | + if (tenantId != null) { | ||
211 | + dashboard.setTenantId(new TenantId(tenantId)); | ||
212 | + } | ||
213 | + if (customerId != null) { | ||
214 | + dashboard.setCustomerId(new CustomerId(customerId)); | ||
215 | + } | ||
216 | + dashboard.setTitle(title); | ||
217 | + dashboard.setConfiguration(configuration); | ||
218 | + return dashboard; | ||
219 | + } | ||
220 | + | ||
221 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import org.thingsboard.server.common.data.DashboardInfo; | ||
25 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
26 | +import org.thingsboard.server.common.data.id.DashboardId; | ||
27 | +import org.thingsboard.server.common.data.id.TenantId; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | + | ||
31 | +import java.util.UUID; | ||
32 | + | ||
33 | +@Entity | ||
34 | +@Table(name = ModelConstants.DASHBOARD_COLUMN_FAMILY_NAME) | ||
35 | +public class DashboardInfoEntity implements SearchTextEntity<DashboardInfo> { | ||
36 | + | ||
37 | + @Transient | ||
38 | + private static final long serialVersionUID = -5525675905528050250L; | ||
39 | + | ||
40 | + @Id | ||
41 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
42 | + private UUID id; | ||
43 | + | ||
44 | + @Column(name = ModelConstants.DASHBOARD_TENANT_ID_PROPERTY) | ||
45 | + private UUID tenantId; | ||
46 | + | ||
47 | + @Column(name = ModelConstants.DASHBOARD_CUSTOMER_ID_PROPERTY) | ||
48 | + private UUID customerId; | ||
49 | + | ||
50 | + @Column(name = ModelConstants.DASHBOARD_TITLE_PROPERTY) | ||
51 | + private String title; | ||
52 | + | ||
53 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
54 | + private String searchText; | ||
55 | + | ||
56 | + public DashboardInfoEntity() { | ||
57 | + super(); | ||
58 | + } | ||
59 | + | ||
60 | + public DashboardInfoEntity(DashboardInfo dashboardInfo) { | ||
61 | + if (dashboardInfo.getId() != null) { | ||
62 | + this.id = dashboardInfo.getId().getId(); | ||
63 | + } | ||
64 | + if (dashboardInfo.getTenantId() != null) { | ||
65 | + this.tenantId = dashboardInfo.getTenantId().getId(); | ||
66 | + } | ||
67 | + if (dashboardInfo.getCustomerId() != null) { | ||
68 | + this.customerId = dashboardInfo.getCustomerId().getId(); | ||
69 | + } | ||
70 | + this.title = dashboardInfo.getTitle(); | ||
71 | + } | ||
72 | + | ||
73 | + public UUID getId() { | ||
74 | + return id; | ||
75 | + } | ||
76 | + | ||
77 | + public void setId(UUID id) { | ||
78 | + this.id = id; | ||
79 | + } | ||
80 | + | ||
81 | + public UUID getTenantId() { | ||
82 | + return tenantId; | ||
83 | + } | ||
84 | + | ||
85 | + public void setTenantId(UUID tenantId) { | ||
86 | + this.tenantId = tenantId; | ||
87 | + } | ||
88 | + | ||
89 | + public UUID getCustomerId() { | ||
90 | + return customerId; | ||
91 | + } | ||
92 | + | ||
93 | + public void setCustomerId(UUID customerId) { | ||
94 | + this.customerId = customerId; | ||
95 | + } | ||
96 | + | ||
97 | + public String getTitle() { | ||
98 | + return title; | ||
99 | + } | ||
100 | + | ||
101 | + public void setTitle(String title) { | ||
102 | + this.title = title; | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + public String getSearchTextSource() { | ||
107 | + return title; | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public void setSearchText(String searchText) { | ||
112 | + this.searchText = searchText; | ||
113 | + } | ||
114 | + | ||
115 | + public String getSearchText() { | ||
116 | + return searchText; | ||
117 | + } | ||
118 | + | ||
119 | + @Override | ||
120 | + public int hashCode() { | ||
121 | + final int prime = 31; | ||
122 | + int result = 1; | ||
123 | + result = prime * result + ((customerId == null) ? 0 : customerId.hashCode()); | ||
124 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
125 | + result = prime * result + ((searchText == null) ? 0 : searchText.hashCode()); | ||
126 | + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); | ||
127 | + result = prime * result + ((title == null) ? 0 : title.hashCode()); | ||
128 | + return result; | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public boolean equals(Object obj) { | ||
133 | + if (this == obj) | ||
134 | + return true; | ||
135 | + if (obj == null) | ||
136 | + return false; | ||
137 | + if (getClass() != obj.getClass()) | ||
138 | + return false; | ||
139 | + DashboardInfoEntity other = (DashboardInfoEntity) obj; | ||
140 | + if (customerId == null) { | ||
141 | + if (other.customerId != null) | ||
142 | + return false; | ||
143 | + } else if (!customerId.equals(other.customerId)) | ||
144 | + return false; | ||
145 | + if (id == null) { | ||
146 | + if (other.id != null) | ||
147 | + return false; | ||
148 | + } else if (!id.equals(other.id)) | ||
149 | + return false; | ||
150 | + if (searchText == null) { | ||
151 | + if (other.searchText != null) | ||
152 | + return false; | ||
153 | + } else if (!searchText.equals(other.searchText)) | ||
154 | + return false; | ||
155 | + if (tenantId == null) { | ||
156 | + if (other.tenantId != null) | ||
157 | + return false; | ||
158 | + } else if (!tenantId.equals(other.tenantId)) | ||
159 | + return false; | ||
160 | + if (title == null) { | ||
161 | + if (other.title != null) | ||
162 | + return false; | ||
163 | + } else if (!title.equals(other.title)) | ||
164 | + return false; | ||
165 | + return true; | ||
166 | + } | ||
167 | + | ||
168 | + @Override | ||
169 | + public String toString() { | ||
170 | + StringBuilder builder = new StringBuilder(); | ||
171 | + builder.append("DashboardInfoEntity [id="); | ||
172 | + builder.append(id); | ||
173 | + builder.append(", tenantId="); | ||
174 | + builder.append(tenantId); | ||
175 | + builder.append(", customerId="); | ||
176 | + builder.append(customerId); | ||
177 | + builder.append(", title="); | ||
178 | + builder.append(title); | ||
179 | + builder.append(", searchText="); | ||
180 | + builder.append(searchText); | ||
181 | + builder.append("]"); | ||
182 | + return builder.toString(); | ||
183 | + } | ||
184 | + | ||
185 | + @Override | ||
186 | + public DashboardInfo toData() { | ||
187 | + DashboardInfo dashboardInfo = new DashboardInfo(new DashboardId(id)); | ||
188 | + dashboardInfo.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
189 | + if (tenantId != null) { | ||
190 | + dashboardInfo.setTenantId(new TenantId(tenantId)); | ||
191 | + } | ||
192 | + if (customerId != null) { | ||
193 | + dashboardInfo.setCustomerId(new CustomerId(customerId)); | ||
194 | + } | ||
195 | + dashboardInfo.setTitle(title); | ||
196 | + return dashboardInfo; | ||
197 | + } | ||
198 | + | ||
199 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import org.thingsboard.server.common.data.id.DeviceCredentialsId; | ||
25 | +import org.thingsboard.server.common.data.id.DeviceId; | ||
26 | +import org.thingsboard.server.common.data.security.DeviceCredentials; | ||
27 | +import org.thingsboard.server.common.data.security.DeviceCredentialsType; | ||
28 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
29 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | + | ||
31 | +import java.util.UUID; | ||
32 | + | ||
33 | +@Entity | ||
34 | +@Table(name = ModelConstants.DEVICE_CREDENTIALS_COLUMN_FAMILY_NAME) | ||
35 | +public final class DeviceCredentialsEntity implements BaseEntity<DeviceCredentials> { | ||
36 | + | ||
37 | + @Transient | ||
38 | + private static final long serialVersionUID = -2512362753385470464L; | ||
39 | + @Id | ||
40 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
41 | + private UUID id; | ||
42 | + | ||
43 | + @Column(name = ModelConstants.DEVICE_CREDENTIALS_DEVICE_ID_PROPERTY) | ||
44 | + private UUID deviceId; | ||
45 | + | ||
46 | + @Column(name = ModelConstants.DEVICE_CREDENTIALS_CREDENTIALS_TYPE_PROPERTY) | ||
47 | + private DeviceCredentialsType credentialsType; | ||
48 | + | ||
49 | + @Column(name = ModelConstants.DEVICE_CREDENTIALS_CREDENTIALS_ID_PROPERTY) | ||
50 | + private String credentialsId; | ||
51 | + | ||
52 | + @Column(name = ModelConstants.DEVICE_CREDENTIALS_CREDENTIALS_VALUE_PROPERTY) | ||
53 | + private String credentialsValue; | ||
54 | + | ||
55 | + public DeviceCredentialsEntity() { | ||
56 | + super(); | ||
57 | + } | ||
58 | + | ||
59 | + public DeviceCredentialsEntity(DeviceCredentials deviceCredentials) { | ||
60 | + if (deviceCredentials.getId() != null) { | ||
61 | + this.id = deviceCredentials.getId().getId(); | ||
62 | + } | ||
63 | + if (deviceCredentials.getDeviceId() != null) { | ||
64 | + this.deviceId = deviceCredentials.getDeviceId().getId(); | ||
65 | + } | ||
66 | + this.credentialsType = deviceCredentials.getCredentialsType(); | ||
67 | + this.credentialsId = deviceCredentials.getCredentialsId(); | ||
68 | + this.credentialsValue = deviceCredentials.getCredentialsValue(); | ||
69 | + } | ||
70 | + | ||
71 | + public UUID getId() { | ||
72 | + return id; | ||
73 | + } | ||
74 | + | ||
75 | + public void setId(UUID id) { | ||
76 | + this.id = id; | ||
77 | + } | ||
78 | + | ||
79 | + public UUID getDeviceId() { | ||
80 | + return deviceId; | ||
81 | + } | ||
82 | + | ||
83 | + public void setDeviceId(UUID deviceId) { | ||
84 | + this.deviceId = deviceId; | ||
85 | + } | ||
86 | + | ||
87 | + public DeviceCredentialsType getCredentialsType() { | ||
88 | + return credentialsType; | ||
89 | + } | ||
90 | + | ||
91 | + public void setCredentialsType(DeviceCredentialsType credentialsType) { | ||
92 | + this.credentialsType = credentialsType; | ||
93 | + } | ||
94 | + | ||
95 | + public String getCredentialsId() { | ||
96 | + return credentialsId; | ||
97 | + } | ||
98 | + | ||
99 | + public void setCredentialsId(String credentialsId) { | ||
100 | + this.credentialsId = credentialsId; | ||
101 | + } | ||
102 | + | ||
103 | + public String getCredentialsValue() { | ||
104 | + return credentialsValue; | ||
105 | + } | ||
106 | + | ||
107 | + public void setCredentialsValue(String credentialsValue) { | ||
108 | + this.credentialsValue = credentialsValue; | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public int hashCode() { | ||
113 | + final int prime = 31; | ||
114 | + int result = 1; | ||
115 | + result = prime * result + ((credentialsId == null) ? 0 : credentialsId.hashCode()); | ||
116 | + result = prime * result + ((credentialsType == null) ? 0 : credentialsType.hashCode()); | ||
117 | + result = prime * result + ((credentialsValue == null) ? 0 : credentialsValue.hashCode()); | ||
118 | + result = prime * result + ((deviceId == null) ? 0 : deviceId.hashCode()); | ||
119 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
120 | + return result; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public boolean equals(Object obj) { | ||
125 | + if (this == obj) | ||
126 | + return true; | ||
127 | + if (obj == null) | ||
128 | + return false; | ||
129 | + if (getClass() != obj.getClass()) | ||
130 | + return false; | ||
131 | + DeviceCredentialsEntity other = (DeviceCredentialsEntity) obj; | ||
132 | + if (credentialsId == null) { | ||
133 | + if (other.credentialsId != null) | ||
134 | + return false; | ||
135 | + } else if (!credentialsId.equals(other.credentialsId)) | ||
136 | + return false; | ||
137 | + if (credentialsType != other.credentialsType) | ||
138 | + return false; | ||
139 | + if (credentialsValue == null) { | ||
140 | + if (other.credentialsValue != null) | ||
141 | + return false; | ||
142 | + } else if (!credentialsValue.equals(other.credentialsValue)) | ||
143 | + return false; | ||
144 | + if (deviceId == null) { | ||
145 | + if (other.deviceId != null) | ||
146 | + return false; | ||
147 | + } else if (!deviceId.equals(other.deviceId)) | ||
148 | + return false; | ||
149 | + if (id == null) { | ||
150 | + if (other.id != null) | ||
151 | + return false; | ||
152 | + } else if (!id.equals(other.id)) | ||
153 | + return false; | ||
154 | + return true; | ||
155 | + } | ||
156 | + | ||
157 | + @Override | ||
158 | + public String toString() { | ||
159 | + StringBuilder builder = new StringBuilder(); | ||
160 | + builder.append("DeviceCredentialsEntity [id="); | ||
161 | + builder.append(id); | ||
162 | + builder.append(", deviceId="); | ||
163 | + builder.append(deviceId); | ||
164 | + builder.append(", credentialsType="); | ||
165 | + builder.append(credentialsType); | ||
166 | + builder.append(", credentialsId="); | ||
167 | + builder.append(credentialsId); | ||
168 | + builder.append(", credentialsValue="); | ||
169 | + builder.append(credentialsValue); | ||
170 | + builder.append("]"); | ||
171 | + return builder.toString(); | ||
172 | + } | ||
173 | + | ||
174 | + @Override | ||
175 | + public DeviceCredentials toData() { | ||
176 | + DeviceCredentials deviceCredentials = new DeviceCredentials(new DeviceCredentialsId(id)); | ||
177 | + deviceCredentials.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
178 | + if (deviceId != null) { | ||
179 | + deviceCredentials.setDeviceId(new DeviceId(deviceId)); | ||
180 | + } | ||
181 | + deviceCredentials.setCredentialsType(credentialsType); | ||
182 | + deviceCredentials.setCredentialsId(credentialsId); | ||
183 | + deviceCredentials.setCredentialsValue(credentialsValue); | ||
184 | + return deviceCredentials; | ||
185 | + } | ||
186 | + | ||
187 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.Device; | ||
26 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
27 | +import org.thingsboard.server.common.data.id.DeviceId; | ||
28 | +import org.thingsboard.server.common.data.id.TenantId; | ||
29 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | + | ||
32 | +import java.util.UUID; | ||
33 | + | ||
34 | +@Entity | ||
35 | +@Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) | ||
36 | +public final class DeviceEntity implements SearchTextEntity<Device> { | ||
37 | + | ||
38 | + @Transient | ||
39 | + private static final long serialVersionUID = 8050086401213322856L; | ||
40 | + | ||
41 | + @Id | ||
42 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
43 | + private UUID id; | ||
44 | + | ||
45 | + @Column(name = ModelConstants.DEVICE_TENANT_ID_PROPERTY) | ||
46 | + private UUID tenantId; | ||
47 | + | ||
48 | + @Column(name = ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY) | ||
49 | + private UUID customerId; | ||
50 | + | ||
51 | + @Column(name = ModelConstants.DEVICE_NAME_PROPERTY) | ||
52 | + private String name; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
55 | + private String searchText; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.DEVICE_ADDITIONAL_INFO_PROPERTY) | ||
58 | + private JsonNode additionalInfo; | ||
59 | + | ||
60 | + public DeviceEntity() { | ||
61 | + super(); | ||
62 | + } | ||
63 | + | ||
64 | + public DeviceEntity(Device device) { | ||
65 | + if (device.getId() != null) { | ||
66 | + this.id = device.getId().getId(); | ||
67 | + } | ||
68 | + if (device.getTenantId() != null) { | ||
69 | + this.tenantId = device.getTenantId().getId(); | ||
70 | + } | ||
71 | + if (device.getCustomerId() != null) { | ||
72 | + this.customerId = device.getCustomerId().getId(); | ||
73 | + } | ||
74 | + this.name = device.getName(); | ||
75 | + this.additionalInfo = device.getAdditionalInfo(); | ||
76 | + } | ||
77 | + | ||
78 | + public UUID getId() { | ||
79 | + return id; | ||
80 | + } | ||
81 | + | ||
82 | + public void setId(UUID id) { | ||
83 | + this.id = id; | ||
84 | + } | ||
85 | + | ||
86 | + public UUID getTenantId() { | ||
87 | + return tenantId; | ||
88 | + } | ||
89 | + | ||
90 | + public void setTenantId(UUID tenantId) { | ||
91 | + this.tenantId = tenantId; | ||
92 | + } | ||
93 | + | ||
94 | + public UUID getCustomerId() { | ||
95 | + return customerId; | ||
96 | + } | ||
97 | + | ||
98 | + public void setCustomerId(UUID customerId) { | ||
99 | + this.customerId = customerId; | ||
100 | + } | ||
101 | + | ||
102 | + public String getName() { | ||
103 | + return name; | ||
104 | + } | ||
105 | + | ||
106 | + public void setName(String name) { | ||
107 | + this.name = name; | ||
108 | + } | ||
109 | + | ||
110 | + public JsonNode getAdditionalInfo() { | ||
111 | + return additionalInfo; | ||
112 | + } | ||
113 | + | ||
114 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
115 | + this.additionalInfo = additionalInfo; | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public String getSearchTextSource() { | ||
120 | + return name; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public void setSearchText(String searchText) { | ||
125 | + this.searchText = searchText; | ||
126 | + } | ||
127 | + | ||
128 | + public String getSearchText() { | ||
129 | + return searchText; | ||
130 | + } | ||
131 | + | ||
132 | + @Override | ||
133 | + public int hashCode() { | ||
134 | + final int prime = 31; | ||
135 | + int result = 1; | ||
136 | + result = prime * result + ((additionalInfo == null) ? 0 : additionalInfo.hashCode()); | ||
137 | + result = prime * result + ((customerId == null) ? 0 : customerId.hashCode()); | ||
138 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
139 | + result = prime * result + ((name == null) ? 0 : name.hashCode()); | ||
140 | + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); | ||
141 | + return result; | ||
142 | + } | ||
143 | + | ||
144 | + @Override | ||
145 | + public boolean equals(Object obj) { | ||
146 | + if (this == obj) | ||
147 | + return true; | ||
148 | + if (obj == null) | ||
149 | + return false; | ||
150 | + if (getClass() != obj.getClass()) | ||
151 | + return false; | ||
152 | + DeviceEntity other = (DeviceEntity) obj; | ||
153 | + if (additionalInfo == null) { | ||
154 | + if (other.additionalInfo != null) | ||
155 | + return false; | ||
156 | + } else if (!additionalInfo.equals(other.additionalInfo)) | ||
157 | + return false; | ||
158 | + if (customerId == null) { | ||
159 | + if (other.customerId != null) | ||
160 | + return false; | ||
161 | + } else if (!customerId.equals(other.customerId)) | ||
162 | + return false; | ||
163 | + if (id == null) { | ||
164 | + if (other.id != null) | ||
165 | + return false; | ||
166 | + } else if (!id.equals(other.id)) | ||
167 | + return false; | ||
168 | + if (name == null) { | ||
169 | + if (other.name != null) | ||
170 | + return false; | ||
171 | + } else if (!name.equals(other.name)) | ||
172 | + return false; | ||
173 | + if (tenantId == null) { | ||
174 | + if (other.tenantId != null) | ||
175 | + return false; | ||
176 | + } else if (!tenantId.equals(other.tenantId)) | ||
177 | + return false; | ||
178 | + return true; | ||
179 | + } | ||
180 | + | ||
181 | + @Override | ||
182 | + public String toString() { | ||
183 | + StringBuilder builder = new StringBuilder(); | ||
184 | + builder.append("DeviceEntity [id="); | ||
185 | + builder.append(id); | ||
186 | + builder.append(", tenantId="); | ||
187 | + builder.append(tenantId); | ||
188 | + builder.append(", customerId="); | ||
189 | + builder.append(customerId); | ||
190 | + builder.append(", name="); | ||
191 | + builder.append(name); | ||
192 | + builder.append(", additionalInfo="); | ||
193 | + builder.append(additionalInfo); | ||
194 | + builder.append("]"); | ||
195 | + return builder.toString(); | ||
196 | + } | ||
197 | + | ||
198 | + @Override | ||
199 | + public Device toData() { | ||
200 | + Device device = new Device(new DeviceId(id)); | ||
201 | + device.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
202 | + if (tenantId != null) { | ||
203 | + device.setTenantId(new TenantId(tenantId)); | ||
204 | + } | ||
205 | + if (customerId != null) { | ||
206 | + device.setCustomerId(new CustomerId(customerId)); | ||
207 | + } | ||
208 | + device.setName(name); | ||
209 | + device.setAdditionalInfo(additionalInfo); | ||
210 | + return device; | ||
211 | + } | ||
212 | + | ||
213 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import lombok.Data; | ||
26 | +import lombok.NoArgsConstructor; | ||
27 | +import org.thingsboard.server.common.data.EntityType; | ||
28 | +import org.thingsboard.server.common.data.Event; | ||
29 | +import org.thingsboard.server.common.data.id.*; | ||
30 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
31 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
32 | + | ||
33 | +import java.util.UUID; | ||
34 | + | ||
35 | +@Data | ||
36 | +@NoArgsConstructor | ||
37 | +@Entity | ||
38 | +@Table(name = ModelConstants.DEVICE_COLUMN_FAMILY_NAME) | ||
39 | +public class EventEntity implements BaseEntity<Event> { | ||
40 | + | ||
41 | + @Transient | ||
42 | + private static final long serialVersionUID = -5717830061727466727L; | ||
43 | + | ||
44 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
45 | + private UUID id; | ||
46 | + | ||
47 | + @Id | ||
48 | + @Column(name = ModelConstants.EVENT_TENANT_ID_PROPERTY) | ||
49 | + private UUID tenantId; | ||
50 | + | ||
51 | + @Column(name = ModelConstants.EVENT_ENTITY_TYPE_PROPERTY) | ||
52 | + private EntityType entityType; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.EVENT_ENTITY_ID_PROPERTY) | ||
55 | + private UUID entityId; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.EVENT_TYPE_PROPERTY) | ||
58 | + private String eventType; | ||
59 | + | ||
60 | + @Column(name = ModelConstants.EVENT_UID_PROPERTY) | ||
61 | + private String eventUId; | ||
62 | + | ||
63 | + @Column(name = ModelConstants.EVENT_BODY_PROPERTY) | ||
64 | + private JsonNode body; | ||
65 | + | ||
66 | + public EventEntity(Event event) { | ||
67 | + if (event.getId() != null) { | ||
68 | + this.id = event.getId().getId(); | ||
69 | + } | ||
70 | + if (event.getTenantId() != null) { | ||
71 | + this.tenantId = event.getTenantId().getId(); | ||
72 | + } | ||
73 | + if (event.getEntityId() != null) { | ||
74 | + this.entityType = event.getEntityId().getEntityType(); | ||
75 | + this.entityId = event.getEntityId().getId(); | ||
76 | + } | ||
77 | + this.eventType = event.getType(); | ||
78 | + this.eventUId = event.getUid(); | ||
79 | + this.body = event.getBody(); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public UUID getId() { | ||
84 | + return id; | ||
85 | + } | ||
86 | + | ||
87 | + @Override | ||
88 | + public void setId(UUID id) { | ||
89 | + this.id = id; | ||
90 | + } | ||
91 | + | ||
92 | + @Override | ||
93 | + public Event toData() { | ||
94 | + Event event = new Event(new EventId(id)); | ||
95 | + event.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
96 | + event.setTenantId(new TenantId(tenantId)); | ||
97 | + switch (entityType) { | ||
98 | + case TENANT: | ||
99 | + event.setEntityId(new TenantId(entityId)); | ||
100 | + break; | ||
101 | + case DEVICE: | ||
102 | + event.setEntityId(new DeviceId(entityId)); | ||
103 | + break; | ||
104 | + case CUSTOMER: | ||
105 | + event.setEntityId(new CustomerId(entityId)); | ||
106 | + break; | ||
107 | + case RULE: | ||
108 | + event.setEntityId(new RuleId(entityId)); | ||
109 | + break; | ||
110 | + case PLUGIN: | ||
111 | + event.setEntityId(new PluginId(entityId)); | ||
112 | + break; | ||
113 | + } | ||
114 | + event.setBody(body); | ||
115 | + event.setType(eventType); | ||
116 | + event.setUid(eventUId); | ||
117 | + return event; | ||
118 | + } | ||
119 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.id.PluginId; | ||
26 | +import org.thingsboard.server.common.data.id.TenantId; | ||
27 | +import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; | ||
28 | +import org.thingsboard.server.common.data.plugin.PluginMetaData; | ||
29 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
30 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
31 | + | ||
32 | +import java.util.Objects; | ||
33 | +import java.util.UUID; | ||
34 | + | ||
35 | +@Entity | ||
36 | +@Table(name = ModelConstants.PLUGIN_COLUMN_FAMILY_NAME) | ||
37 | +public class PluginMetaDataEntity implements SearchTextEntity<PluginMetaData> { | ||
38 | + | ||
39 | + @Transient | ||
40 | + private static final long serialVersionUID = -6164321050824823149L; | ||
41 | + @Id | ||
42 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
43 | + private UUID id; | ||
44 | + | ||
45 | + @Column(name = ModelConstants.PLUGIN_API_TOKEN_PROPERTY) | ||
46 | + private String apiToken; | ||
47 | + | ||
48 | + @Column(name = ModelConstants.PLUGIN_TENANT_ID_PROPERTY) | ||
49 | + private UUID tenantId; | ||
50 | + | ||
51 | + @Column(name = ModelConstants.PLUGIN_NAME_PROPERTY) | ||
52 | + private String name; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.PLUGIN_CLASS_PROPERTY) | ||
55 | + private String clazz; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.PLUGIN_ACCESS_PROPERTY) | ||
58 | + private boolean publicAccess; | ||
59 | + | ||
60 | + @Column(name = ModelConstants.PLUGIN_STATE_PROPERTY) | ||
61 | + private ComponentLifecycleState state; | ||
62 | + | ||
63 | + @Column(name = ModelConstants.PLUGIN_CONFIGURATION_PROPERTY) | ||
64 | + private JsonNode configuration; | ||
65 | + | ||
66 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
67 | + private String searchText; | ||
68 | + | ||
69 | + @Column(name = ModelConstants.ADDITIONAL_INFO_PROPERTY) | ||
70 | + private JsonNode additionalInfo; | ||
71 | + | ||
72 | + public PluginMetaDataEntity() { | ||
73 | + } | ||
74 | + | ||
75 | + public PluginMetaDataEntity(PluginMetaData pluginMetaData) { | ||
76 | + if (pluginMetaData.getId() != null) { | ||
77 | + this.id = pluginMetaData.getId().getId(); | ||
78 | + } | ||
79 | + this.tenantId = pluginMetaData.getTenantId().getId(); | ||
80 | + this.apiToken = pluginMetaData.getApiToken(); | ||
81 | + this.clazz = pluginMetaData.getClazz(); | ||
82 | + this.name = pluginMetaData.getName(); | ||
83 | + this.publicAccess = pluginMetaData.isPublicAccess(); | ||
84 | + this.state = pluginMetaData.getState(); | ||
85 | + this.configuration = pluginMetaData.getConfiguration(); | ||
86 | + this.searchText = pluginMetaData.getName(); | ||
87 | + this.additionalInfo = pluginMetaData.getAdditionalInfo(); | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public String getSearchTextSource() { | ||
92 | + return searchText; | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public void setSearchText(String searchText) { | ||
97 | + this.searchText = searchText; | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public UUID getId() { | ||
102 | + return id; | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + public void setId(UUID id) { | ||
107 | + this.id = id; | ||
108 | + } | ||
109 | + | ||
110 | + public String getApiToken() { | ||
111 | + return apiToken; | ||
112 | + } | ||
113 | + | ||
114 | + public void setApiToken(String apiToken) { | ||
115 | + this.apiToken = apiToken; | ||
116 | + } | ||
117 | + | ||
118 | + public UUID getTenantId() { | ||
119 | + return tenantId; | ||
120 | + } | ||
121 | + | ||
122 | + public void setTenantId(UUID tenantId) { | ||
123 | + this.tenantId = tenantId; | ||
124 | + } | ||
125 | + | ||
126 | + public String getName() { | ||
127 | + return name; | ||
128 | + } | ||
129 | + | ||
130 | + public void setName(String name) { | ||
131 | + this.name = name; | ||
132 | + } | ||
133 | + | ||
134 | + public String getClazz() { | ||
135 | + return clazz; | ||
136 | + } | ||
137 | + | ||
138 | + public void setClazz(String clazz) { | ||
139 | + this.clazz = clazz; | ||
140 | + } | ||
141 | + | ||
142 | + public JsonNode getConfiguration() { | ||
143 | + return configuration; | ||
144 | + } | ||
145 | + | ||
146 | + public void setConfiguration(JsonNode configuration) { | ||
147 | + this.configuration = configuration; | ||
148 | + } | ||
149 | + | ||
150 | + public boolean isPublicAccess() { | ||
151 | + return publicAccess; | ||
152 | + } | ||
153 | + | ||
154 | + public void setPublicAccess(boolean publicAccess) { | ||
155 | + this.publicAccess = publicAccess; | ||
156 | + } | ||
157 | + | ||
158 | + public ComponentLifecycleState getState() { | ||
159 | + return state; | ||
160 | + } | ||
161 | + | ||
162 | + public void setState(ComponentLifecycleState state) { | ||
163 | + this.state = state; | ||
164 | + } | ||
165 | + | ||
166 | + public String getSearchText() { | ||
167 | + return searchText; | ||
168 | + } | ||
169 | + | ||
170 | + public JsonNode getAdditionalInfo() { | ||
171 | + return additionalInfo; | ||
172 | + } | ||
173 | + | ||
174 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
175 | + this.additionalInfo = additionalInfo; | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public PluginMetaData toData() { | ||
180 | + PluginMetaData data = new PluginMetaData(new PluginId(id)); | ||
181 | + data.setTenantId(new TenantId(tenantId)); | ||
182 | + data.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
183 | + data.setName(name); | ||
184 | + data.setConfiguration(configuration); | ||
185 | + data.setClazz(clazz); | ||
186 | + data.setPublicAccess(publicAccess); | ||
187 | + data.setState(state); | ||
188 | + data.setApiToken(apiToken); | ||
189 | + data.setAdditionalInfo(additionalInfo); | ||
190 | + return data; | ||
191 | + } | ||
192 | + | ||
193 | + @Override | ||
194 | + public boolean equals(Object o) { | ||
195 | + if (this == o) | ||
196 | + return true; | ||
197 | + if (o == null || getClass() != o.getClass()) | ||
198 | + return false; | ||
199 | + PluginMetaDataEntity entity = (PluginMetaDataEntity) o; | ||
200 | + return Objects.equals(id, entity.id) && Objects.equals(apiToken, entity.apiToken) && Objects.equals(tenantId, entity.tenantId) | ||
201 | + && Objects.equals(name, entity.name) && Objects.equals(clazz, entity.clazz) && Objects.equals(state, entity.state) | ||
202 | + && Objects.equals(configuration, entity.configuration) | ||
203 | + && Objects.equals(searchText, entity.searchText); | ||
204 | + } | ||
205 | + | ||
206 | + @Override | ||
207 | + public int hashCode() { | ||
208 | + return Objects.hash(id, apiToken, tenantId, name, clazz, state, configuration, searchText); | ||
209 | + } | ||
210 | + | ||
211 | + @Override | ||
212 | + public String toString() { | ||
213 | + return "PluginMetaDataEntity{" + "id=" + id + ", apiToken='" + apiToken + '\'' + ", tenantId=" + tenantId + ", name='" + name + '\'' + ", clazz='" | ||
214 | + + clazz + '\'' + ", state=" + state + ", configuration=" + configuration + ", searchText='" + searchText + '\'' + '}'; | ||
215 | + } | ||
216 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import com.fasterxml.jackson.databind.JsonNode; | ||
25 | +import org.thingsboard.server.common.data.id.RuleId; | ||
26 | +import org.thingsboard.server.common.data.id.TenantId; | ||
27 | +import org.thingsboard.server.common.data.plugin.ComponentLifecycleState; | ||
28 | +import org.thingsboard.server.common.data.rule.RuleMetaData; | ||
29 | +import org.thingsboard.server.dao.DaoUtil; | ||
30 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
31 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
32 | + | ||
33 | +import java.util.Objects; | ||
34 | +import java.util.UUID; | ||
35 | + | ||
36 | +@Entity | ||
37 | +@Table(name = ModelConstants.RULE_COLUMN_FAMILY_NAME) | ||
38 | +public class RuleMetaDataEntity implements SearchTextEntity<RuleMetaData> { | ||
39 | + | ||
40 | + @Transient | ||
41 | + private static final long serialVersionUID = -1506905644259463884L; | ||
42 | + @Id | ||
43 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
44 | + private UUID id; | ||
45 | + @Column(name = ModelConstants.RULE_TENANT_ID_PROPERTY) | ||
46 | + private UUID tenantId; | ||
47 | + @Column(name = ModelConstants.RULE_NAME_PROPERTY) | ||
48 | + private String name; | ||
49 | + @Column(name = ModelConstants.RULE_STATE_PROPERTY) | ||
50 | + private ComponentLifecycleState state; | ||
51 | + @Column(name = ModelConstants.RULE_WEIGHT_PROPERTY) | ||
52 | + private int weight; | ||
53 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
54 | + private String searchText; | ||
55 | + @Column(name = ModelConstants.RULE_PLUGIN_TOKEN_PROPERTY) | ||
56 | + private String pluginToken; | ||
57 | + @Column(name = ModelConstants.RULE_FILTERS) | ||
58 | + private JsonNode filters; | ||
59 | + @Column(name = ModelConstants.RULE_PROCESSOR) | ||
60 | + private JsonNode processor; | ||
61 | + @Column(name = ModelConstants.RULE_ACTION) | ||
62 | + private JsonNode action; | ||
63 | + @Column(name = ModelConstants.ADDITIONAL_INFO_PROPERTY) | ||
64 | + private JsonNode additionalInfo; | ||
65 | + | ||
66 | + public RuleMetaDataEntity() { | ||
67 | + } | ||
68 | + | ||
69 | + public RuleMetaDataEntity(RuleMetaData rule) { | ||
70 | + if (rule.getId() != null) { | ||
71 | + this.id = rule.getUuidId(); | ||
72 | + } | ||
73 | + this.tenantId = DaoUtil.getId(rule.getTenantId()); | ||
74 | + this.name = rule.getName(); | ||
75 | + this.pluginToken = rule.getPluginToken(); | ||
76 | + this.state = rule.getState(); | ||
77 | + this.weight = rule.getWeight(); | ||
78 | + this.searchText = rule.getName(); | ||
79 | + this.filters = rule.getFilters(); | ||
80 | + this.processor = rule.getProcessor(); | ||
81 | + this.action = rule.getAction(); | ||
82 | + this.additionalInfo = rule.getAdditionalInfo(); | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public String getSearchTextSource() { | ||
87 | + return searchText; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
91 | + public void setSearchText(String searchText) { | ||
92 | + this.searchText = searchText; | ||
93 | + } | ||
94 | + | ||
95 | + @Override | ||
96 | + public UUID getId() { | ||
97 | + return id; | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public void setId(UUID id) { | ||
102 | + this.id = id; | ||
103 | + } | ||
104 | + | ||
105 | + public UUID getTenantId() { | ||
106 | + return tenantId; | ||
107 | + } | ||
108 | + | ||
109 | + public void setTenantId(UUID tenantId) { | ||
110 | + this.tenantId = tenantId; | ||
111 | + } | ||
112 | + | ||
113 | + public String getName() { | ||
114 | + return name; | ||
115 | + } | ||
116 | + | ||
117 | + public void setName(String name) { | ||
118 | + this.name = name; | ||
119 | + } | ||
120 | + | ||
121 | + public ComponentLifecycleState getState() { | ||
122 | + return state; | ||
123 | + } | ||
124 | + | ||
125 | + public void setState(ComponentLifecycleState state) { | ||
126 | + this.state = state; | ||
127 | + } | ||
128 | + | ||
129 | + public int getWeight() { | ||
130 | + return weight; | ||
131 | + } | ||
132 | + | ||
133 | + public void setWeight(int weight) { | ||
134 | + this.weight = weight; | ||
135 | + } | ||
136 | + | ||
137 | + public String getPluginToken() { | ||
138 | + return pluginToken; | ||
139 | + } | ||
140 | + | ||
141 | + public void setPluginToken(String pluginToken) { | ||
142 | + this.pluginToken = pluginToken; | ||
143 | + } | ||
144 | + | ||
145 | + public String getSearchText() { | ||
146 | + return searchText; | ||
147 | + } | ||
148 | + | ||
149 | + public JsonNode getFilters() { | ||
150 | + return filters; | ||
151 | + } | ||
152 | + | ||
153 | + public void setFilters(JsonNode filters) { | ||
154 | + this.filters = filters; | ||
155 | + } | ||
156 | + | ||
157 | + public JsonNode getProcessor() { | ||
158 | + return processor; | ||
159 | + } | ||
160 | + | ||
161 | + public void setProcessor(JsonNode processor) { | ||
162 | + this.processor = processor; | ||
163 | + } | ||
164 | + | ||
165 | + public JsonNode getAction() { | ||
166 | + return action; | ||
167 | + } | ||
168 | + | ||
169 | + public void setAction(JsonNode action) { | ||
170 | + this.action = action; | ||
171 | + } | ||
172 | + | ||
173 | + public JsonNode getAdditionalInfo() { | ||
174 | + return additionalInfo; | ||
175 | + } | ||
176 | + | ||
177 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
178 | + this.additionalInfo = additionalInfo; | ||
179 | + } | ||
180 | + | ||
181 | + @Override | ||
182 | + public RuleMetaData toData() { | ||
183 | + RuleMetaData rule = new RuleMetaData(new RuleId(id)); | ||
184 | + rule.setTenantId(new TenantId(tenantId)); | ||
185 | + rule.setName(name); | ||
186 | + rule.setState(state); | ||
187 | + rule.setWeight(weight); | ||
188 | + rule.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
189 | + rule.setPluginToken(pluginToken); | ||
190 | + rule.setFilters(filters); | ||
191 | + rule.setProcessor(processor); | ||
192 | + rule.setAction(action); | ||
193 | + rule.setAdditionalInfo(additionalInfo); | ||
194 | + return rule; | ||
195 | + } | ||
196 | + | ||
197 | + @Override | ||
198 | + public boolean equals(Object o) { | ||
199 | + if (this == o) return true; | ||
200 | + if (o == null || getClass() != o.getClass()) return false; | ||
201 | + RuleMetaDataEntity that = (RuleMetaDataEntity) o; | ||
202 | + return weight == that.weight && | ||
203 | + Objects.equals(id, that.id) && | ||
204 | + Objects.equals(tenantId, that.tenantId) && | ||
205 | + Objects.equals(name, that.name) && | ||
206 | + Objects.equals(pluginToken, that.pluginToken) && | ||
207 | + Objects.equals(state, that.state) && | ||
208 | + Objects.equals(searchText, that.searchText); | ||
209 | + } | ||
210 | + | ||
211 | + @Override | ||
212 | + public int hashCode() { | ||
213 | + return Objects.hash(id, tenantId, name, pluginToken, state, weight, searchText); | ||
214 | + } | ||
215 | + | ||
216 | + @Override | ||
217 | + public String toString() { | ||
218 | + return "RuleMetaDataEntity{" + | ||
219 | + "id=" + id + | ||
220 | + ", tenantId=" + tenantId + | ||
221 | + ", name='" + name + '\'' + | ||
222 | + ", pluginToken='" + pluginToken + '\'' + | ||
223 | + ", state='" + state + '\'' + | ||
224 | + ", weight=" + weight + | ||
225 | + ", searchText='" + searchText + '\'' + | ||
226 | + '}'; | ||
227 | + } | ||
228 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import org.thingsboard.server.common.data.Tenant; | ||
25 | +import org.thingsboard.server.common.data.id.TenantId; | ||
26 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
27 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
28 | +import com.fasterxml.jackson.databind.JsonNode; | ||
29 | + | ||
30 | +import java.util.UUID; | ||
31 | + | ||
32 | +@Entity | ||
33 | +@Table(name = ModelConstants.TENANT_COLUMN_FAMILY_NAME) | ||
34 | +public final class TenantEntity implements SearchTextEntity<Tenant> { | ||
35 | + | ||
36 | + @Transient | ||
37 | + private static final long serialVersionUID = -4330655990232136337L; | ||
38 | + | ||
39 | + @Id | ||
40 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
41 | + private UUID id; | ||
42 | + | ||
43 | + @Column(name = ModelConstants.TENANT_TITLE_PROPERTY) | ||
44 | + private String title; | ||
45 | + | ||
46 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
47 | + private String searchText; | ||
48 | + | ||
49 | + @Column(name = ModelConstants.TENANT_REGION_PROPERTY) | ||
50 | + private String region; | ||
51 | + | ||
52 | + @Column(name = ModelConstants.COUNTRY_PROPERTY) | ||
53 | + private String country; | ||
54 | + | ||
55 | + @Column(name = ModelConstants.STATE_PROPERTY) | ||
56 | + private String state; | ||
57 | + | ||
58 | + @Column(name = ModelConstants.CITY_PROPERTY) | ||
59 | + private String city; | ||
60 | + | ||
61 | + @Column(name = ModelConstants.ADDRESS_PROPERTY) | ||
62 | + private String address; | ||
63 | + | ||
64 | + @Column(name = ModelConstants.ADDRESS2_PROPERTY) | ||
65 | + private String address2; | ||
66 | + | ||
67 | + @Column(name = ModelConstants.ZIP_PROPERTY) | ||
68 | + private String zip; | ||
69 | + | ||
70 | + @Column(name = ModelConstants.PHONE_PROPERTY) | ||
71 | + private String phone; | ||
72 | + | ||
73 | + @Column(name = ModelConstants.EMAIL_PROPERTY) | ||
74 | + private String email; | ||
75 | + | ||
76 | + @Column(name = ModelConstants.TENANT_ADDITIONAL_INFO_PROPERTY) | ||
77 | + private JsonNode additionalInfo; | ||
78 | + | ||
79 | + public TenantEntity() { | ||
80 | + super(); | ||
81 | + } | ||
82 | + | ||
83 | + public TenantEntity(Tenant tenant) { | ||
84 | + if (tenant.getId() != null) { | ||
85 | + this.id = tenant.getId().getId(); | ||
86 | + } | ||
87 | + this.title = tenant.getTitle(); | ||
88 | + this.region = tenant.getRegion(); | ||
89 | + this.country = tenant.getCountry(); | ||
90 | + this.state = tenant.getState(); | ||
91 | + this.city = tenant.getCity(); | ||
92 | + this.address = tenant.getAddress(); | ||
93 | + this.address2 = tenant.getAddress2(); | ||
94 | + this.zip = tenant.getZip(); | ||
95 | + this.phone = tenant.getPhone(); | ||
96 | + this.email = tenant.getEmail(); | ||
97 | + this.additionalInfo = tenant.getAdditionalInfo(); | ||
98 | + } | ||
99 | + | ||
100 | + public UUID getId() { | ||
101 | + return id; | ||
102 | + } | ||
103 | + | ||
104 | + public void setId(UUID id) { | ||
105 | + this.id = id; | ||
106 | + } | ||
107 | + | ||
108 | + public String getTitle() { | ||
109 | + return title; | ||
110 | + } | ||
111 | + | ||
112 | + public void setTitle(String title) { | ||
113 | + this.title = title; | ||
114 | + } | ||
115 | + | ||
116 | + public String getRegion() { | ||
117 | + return region; | ||
118 | + } | ||
119 | + | ||
120 | + public void setRegion(String region) { | ||
121 | + this.region = region; | ||
122 | + } | ||
123 | + | ||
124 | + public String getCountry() { | ||
125 | + return country; | ||
126 | + } | ||
127 | + | ||
128 | + public void setCountry(String country) { | ||
129 | + this.country = country; | ||
130 | + } | ||
131 | + | ||
132 | + public String getState() { | ||
133 | + return state; | ||
134 | + } | ||
135 | + | ||
136 | + public void setState(String state) { | ||
137 | + this.state = state; | ||
138 | + } | ||
139 | + | ||
140 | + public String getCity() { | ||
141 | + return city; | ||
142 | + } | ||
143 | + | ||
144 | + public void setCity(String city) { | ||
145 | + this.city = city; | ||
146 | + } | ||
147 | + | ||
148 | + public String getAddress() { | ||
149 | + return address; | ||
150 | + } | ||
151 | + | ||
152 | + public void setAddress(String address) { | ||
153 | + this.address = address; | ||
154 | + } | ||
155 | + | ||
156 | + public String getAddress2() { | ||
157 | + return address2; | ||
158 | + } | ||
159 | + | ||
160 | + public void setAddress2(String address2) { | ||
161 | + this.address2 = address2; | ||
162 | + } | ||
163 | + | ||
164 | + public String getZip() { | ||
165 | + return zip; | ||
166 | + } | ||
167 | + | ||
168 | + public void setZip(String zip) { | ||
169 | + this.zip = zip; | ||
170 | + } | ||
171 | + | ||
172 | + public String getPhone() { | ||
173 | + return phone; | ||
174 | + } | ||
175 | + | ||
176 | + public void setPhone(String phone) { | ||
177 | + this.phone = phone; | ||
178 | + } | ||
179 | + | ||
180 | + public String getEmail() { | ||
181 | + return email; | ||
182 | + } | ||
183 | + | ||
184 | + public void setEmail(String email) { | ||
185 | + this.email = email; | ||
186 | + } | ||
187 | + | ||
188 | + public JsonNode getAdditionalInfo() { | ||
189 | + return additionalInfo; | ||
190 | + } | ||
191 | + | ||
192 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
193 | + this.additionalInfo = additionalInfo; | ||
194 | + } | ||
195 | + | ||
196 | + @Override | ||
197 | + public String getSearchTextSource() { | ||
198 | + return title; | ||
199 | + } | ||
200 | + | ||
201 | + @Override | ||
202 | + public void setSearchText(String searchText) { | ||
203 | + this.searchText = searchText; | ||
204 | + } | ||
205 | + | ||
206 | + public String getSearchText() { | ||
207 | + return searchText; | ||
208 | + } | ||
209 | + | ||
210 | + @Override | ||
211 | + public int hashCode() { | ||
212 | + final int prime = 31; | ||
213 | + int result = 1; | ||
214 | + result = prime * result + ((additionalInfo == null) ? 0 : additionalInfo.hashCode()); | ||
215 | + result = prime * result + ((address == null) ? 0 : address.hashCode()); | ||
216 | + result = prime * result + ((address2 == null) ? 0 : address2.hashCode()); | ||
217 | + result = prime * result + ((city == null) ? 0 : city.hashCode()); | ||
218 | + result = prime * result + ((country == null) ? 0 : country.hashCode()); | ||
219 | + result = prime * result + ((email == null) ? 0 : email.hashCode()); | ||
220 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
221 | + result = prime * result + ((phone == null) ? 0 : phone.hashCode()); | ||
222 | + result = prime * result + ((region == null) ? 0 : region.hashCode()); | ||
223 | + result = prime * result + ((state == null) ? 0 : state.hashCode()); | ||
224 | + result = prime * result + ((title == null) ? 0 : title.hashCode()); | ||
225 | + result = prime * result + ((zip == null) ? 0 : zip.hashCode()); | ||
226 | + return result; | ||
227 | + } | ||
228 | + | ||
229 | + @Override | ||
230 | + public boolean equals(Object obj) { | ||
231 | + if (this == obj) | ||
232 | + return true; | ||
233 | + if (obj == null) | ||
234 | + return false; | ||
235 | + if (getClass() != obj.getClass()) | ||
236 | + return false; | ||
237 | + TenantEntity other = (TenantEntity) obj; | ||
238 | + if (additionalInfo == null) { | ||
239 | + if (other.additionalInfo != null) | ||
240 | + return false; | ||
241 | + } else if (!additionalInfo.equals(other.additionalInfo)) | ||
242 | + return false; | ||
243 | + if (address == null) { | ||
244 | + if (other.address != null) | ||
245 | + return false; | ||
246 | + } else if (!address.equals(other.address)) | ||
247 | + return false; | ||
248 | + if (address2 == null) { | ||
249 | + if (other.address2 != null) | ||
250 | + return false; | ||
251 | + } else if (!address2.equals(other.address2)) | ||
252 | + return false; | ||
253 | + if (city == null) { | ||
254 | + if (other.city != null) | ||
255 | + return false; | ||
256 | + } else if (!city.equals(other.city)) | ||
257 | + return false; | ||
258 | + if (country == null) { | ||
259 | + if (other.country != null) | ||
260 | + return false; | ||
261 | + } else if (!country.equals(other.country)) | ||
262 | + return false; | ||
263 | + if (email == null) { | ||
264 | + if (other.email != null) | ||
265 | + return false; | ||
266 | + } else if (!email.equals(other.email)) | ||
267 | + return false; | ||
268 | + if (id == null) { | ||
269 | + if (other.id != null) | ||
270 | + return false; | ||
271 | + } else if (!id.equals(other.id)) | ||
272 | + return false; | ||
273 | + if (phone == null) { | ||
274 | + if (other.phone != null) | ||
275 | + return false; | ||
276 | + } else if (!phone.equals(other.phone)) | ||
277 | + return false; | ||
278 | + if (region == null) { | ||
279 | + if (other.region != null) | ||
280 | + return false; | ||
281 | + } else if (!region.equals(other.region)) | ||
282 | + return false; | ||
283 | + if (state == null) { | ||
284 | + if (other.state != null) | ||
285 | + return false; | ||
286 | + } else if (!state.equals(other.state)) | ||
287 | + return false; | ||
288 | + if (title == null) { | ||
289 | + if (other.title != null) | ||
290 | + return false; | ||
291 | + } else if (!title.equals(other.title)) | ||
292 | + return false; | ||
293 | + if (zip == null) { | ||
294 | + if (other.zip != null) | ||
295 | + return false; | ||
296 | + } else if (!zip.equals(other.zip)) | ||
297 | + return false; | ||
298 | + return true; | ||
299 | + } | ||
300 | + | ||
301 | + @Override | ||
302 | + public String toString() { | ||
303 | + StringBuilder builder = new StringBuilder(); | ||
304 | + builder.append("TenantEntity [id="); | ||
305 | + builder.append(id); | ||
306 | + builder.append(", title="); | ||
307 | + builder.append(title); | ||
308 | + builder.append(", region="); | ||
309 | + builder.append(region); | ||
310 | + builder.append(", country="); | ||
311 | + builder.append(country); | ||
312 | + builder.append(", state="); | ||
313 | + builder.append(state); | ||
314 | + builder.append(", city="); | ||
315 | + builder.append(city); | ||
316 | + builder.append(", address="); | ||
317 | + builder.append(address); | ||
318 | + builder.append(", address2="); | ||
319 | + builder.append(address2); | ||
320 | + builder.append(", zip="); | ||
321 | + builder.append(zip); | ||
322 | + builder.append(", phone="); | ||
323 | + builder.append(phone); | ||
324 | + builder.append(", email="); | ||
325 | + builder.append(email); | ||
326 | + builder.append(", additionalInfo="); | ||
327 | + builder.append(additionalInfo); | ||
328 | + builder.append("]"); | ||
329 | + return builder.toString(); | ||
330 | + } | ||
331 | + | ||
332 | + @Override | ||
333 | + public Tenant toData() { | ||
334 | + Tenant tenant = new Tenant(new TenantId(id)); | ||
335 | + tenant.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
336 | + tenant.setTitle(title); | ||
337 | + tenant.setRegion(region); | ||
338 | + tenant.setCountry(country); | ||
339 | + tenant.setState(state); | ||
340 | + tenant.setCity(city); | ||
341 | + tenant.setAddress(address); | ||
342 | + tenant.setAddress2(address2); | ||
343 | + tenant.setZip(zip); | ||
344 | + tenant.setPhone(phone); | ||
345 | + tenant.setEmail(email); | ||
346 | + tenant.setAdditionalInfo(additionalInfo); | ||
347 | + return tenant; | ||
348 | + } | ||
349 | + | ||
350 | + | ||
351 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | +import org.thingsboard.server.common.data.id.UserCredentialsId; | ||
25 | +import org.thingsboard.server.common.data.id.UserId; | ||
26 | +import org.thingsboard.server.common.data.security.UserCredentials; | ||
27 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | + | ||
30 | +import java.util.UUID; | ||
31 | + | ||
32 | +@Entity | ||
33 | +@Table(name = ModelConstants.USER_CREDENTIALS_COLUMN_FAMILY_NAME) | ||
34 | +public final class UserCredentialsEntity implements BaseEntity<UserCredentials> { | ||
35 | + | ||
36 | + @Transient | ||
37 | + private static final long serialVersionUID = 1348221414123438374L; | ||
38 | + | ||
39 | + @Id | ||
40 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
41 | + private UUID id; | ||
42 | + | ||
43 | + @Column(name = ModelConstants.USER_CREDENTIALS_USER_ID_PROPERTY) | ||
44 | + private UUID userId; | ||
45 | + | ||
46 | + @Column(name = ModelConstants.USER_CREDENTIALS_ENABLED_PROPERTY) | ||
47 | + private boolean enabled; | ||
48 | + | ||
49 | + @Column(name = ModelConstants.USER_CREDENTIALS_PASSWORD_PROPERTY) | ||
50 | + private String password; | ||
51 | + | ||
52 | + @Column(name = ModelConstants.USER_CREDENTIALS_ACTIVATE_TOKEN_PROPERTY) | ||
53 | + private String activateToken; | ||
54 | + | ||
55 | + @Column(name = ModelConstants.USER_CREDENTIALS_RESET_TOKEN_PROPERTY) | ||
56 | + private String resetToken; | ||
57 | + | ||
58 | + public UserCredentialsEntity() { | ||
59 | + super(); | ||
60 | + } | ||
61 | + | ||
62 | + public UserCredentialsEntity(UserCredentials userCredentials) { | ||
63 | + if (userCredentials.getId() != null) { | ||
64 | + this.id = userCredentials.getId().getId(); | ||
65 | + } | ||
66 | + if (userCredentials.getUserId() != null) { | ||
67 | + this.userId = userCredentials.getUserId().getId(); | ||
68 | + } | ||
69 | + this.enabled = userCredentials.isEnabled(); | ||
70 | + this.password = userCredentials.getPassword(); | ||
71 | + this.activateToken = userCredentials.getActivateToken(); | ||
72 | + this.resetToken = userCredentials.getResetToken(); | ||
73 | + } | ||
74 | + | ||
75 | + public UUID getId() { | ||
76 | + return id; | ||
77 | + } | ||
78 | + | ||
79 | + public void setId(UUID id) { | ||
80 | + this.id = id; | ||
81 | + } | ||
82 | + | ||
83 | + public UUID getUserId() { | ||
84 | + return userId; | ||
85 | + } | ||
86 | + | ||
87 | + public void setUserId(UUID userId) { | ||
88 | + this.userId = userId; | ||
89 | + } | ||
90 | + | ||
91 | + public boolean isEnabled() { | ||
92 | + return enabled; | ||
93 | + } | ||
94 | + | ||
95 | + public void setEnabled(boolean enabled) { | ||
96 | + this.enabled = enabled; | ||
97 | + } | ||
98 | + | ||
99 | + public String getPassword() { | ||
100 | + return password; | ||
101 | + } | ||
102 | + | ||
103 | + public void setPassword(String password) { | ||
104 | + this.password = password; | ||
105 | + } | ||
106 | + | ||
107 | + public String getActivateToken() { | ||
108 | + return activateToken; | ||
109 | + } | ||
110 | + | ||
111 | + public void setActivateToken(String activateToken) { | ||
112 | + this.activateToken = activateToken; | ||
113 | + } | ||
114 | + | ||
115 | + public String getResetToken() { | ||
116 | + return resetToken; | ||
117 | + } | ||
118 | + | ||
119 | + public void setResetToken(String resetToken) { | ||
120 | + this.resetToken = resetToken; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public int hashCode() { | ||
125 | + final int prime = 31; | ||
126 | + int result = 1; | ||
127 | + result = prime * result + ((activateToken == null) ? 0 : activateToken.hashCode()); | ||
128 | + result = prime * result + (enabled ? 1231 : 1237); | ||
129 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
130 | + result = prime * result + ((password == null) ? 0 : password.hashCode()); | ||
131 | + result = prime * result + ((resetToken == null) ? 0 : resetToken.hashCode()); | ||
132 | + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); | ||
133 | + return result; | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public boolean equals(Object obj) { | ||
138 | + if (this == obj) | ||
139 | + return true; | ||
140 | + if (obj == null) | ||
141 | + return false; | ||
142 | + if (getClass() != obj.getClass()) | ||
143 | + return false; | ||
144 | + UserCredentialsEntity other = (UserCredentialsEntity) obj; | ||
145 | + if (activateToken == null) { | ||
146 | + if (other.activateToken != null) | ||
147 | + return false; | ||
148 | + } else if (!activateToken.equals(other.activateToken)) | ||
149 | + return false; | ||
150 | + if (enabled != other.enabled) | ||
151 | + return false; | ||
152 | + if (id == null) { | ||
153 | + if (other.id != null) | ||
154 | + return false; | ||
155 | + } else if (!id.equals(other.id)) | ||
156 | + return false; | ||
157 | + if (password == null) { | ||
158 | + if (other.password != null) | ||
159 | + return false; | ||
160 | + } else if (!password.equals(other.password)) | ||
161 | + return false; | ||
162 | + if (resetToken == null) { | ||
163 | + if (other.resetToken != null) | ||
164 | + return false; | ||
165 | + } else if (!resetToken.equals(other.resetToken)) | ||
166 | + return false; | ||
167 | + if (userId == null) { | ||
168 | + if (other.userId != null) | ||
169 | + return false; | ||
170 | + } else if (!userId.equals(other.userId)) | ||
171 | + return false; | ||
172 | + return true; | ||
173 | + } | ||
174 | + | ||
175 | + @Override | ||
176 | + public UserCredentials toData() { | ||
177 | + UserCredentials userCredentials = new UserCredentials(new UserCredentialsId(id)); | ||
178 | + userCredentials.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
179 | + if (userId != null) { | ||
180 | + userCredentials.setUserId(new UserId(userId)); | ||
181 | + } | ||
182 | + userCredentials.setEnabled(enabled); | ||
183 | + userCredentials.setPassword(password); | ||
184 | + userCredentials.setActivateToken(activateToken); | ||
185 | + userCredentials.setResetToken(resetToken); | ||
186 | + return userCredentials; | ||
187 | + } | ||
188 | + | ||
189 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import com.fasterxml.jackson.databind.JsonNode; | ||
20 | +import org.thingsboard.server.common.data.User; | ||
21 | +import org.thingsboard.server.common.data.id.CustomerId; | ||
22 | +import org.thingsboard.server.common.data.id.TenantId; | ||
23 | +import org.thingsboard.server.common.data.id.UserId; | ||
24 | +import org.thingsboard.server.common.data.security.Authority; | ||
25 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
26 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
27 | + | ||
28 | +import javax.persistence.Column; | ||
29 | +import javax.persistence.Entity; | ||
30 | +import javax.persistence.Id; | ||
31 | +import javax.persistence.Table; | ||
32 | +import javax.persistence.Transient; | ||
33 | +import java.util.UUID; | ||
34 | + | ||
35 | +/** | ||
36 | + * @author Valerii Sosliuk | ||
37 | + */ | ||
38 | +@Entity | ||
39 | +@Table(name= ModelConstants.USER_COLUMN_FAMILY_NAME) | ||
40 | +public class UserEntity implements SearchTextEntity<User> { | ||
41 | + | ||
42 | + @Transient | ||
43 | + private static final long serialVersionUID = 4349485207981226785L; | ||
44 | + | ||
45 | + @Id | ||
46 | + @Column(name=ModelConstants.ID_PROPERTY) | ||
47 | + private UUID id; | ||
48 | + | ||
49 | + @Column(name = ModelConstants.USER_TENANT_ID_PROPERTY) | ||
50 | + private UUID tenantId; | ||
51 | + | ||
52 | + @Column(name = ModelConstants.USER_CUSTOMER_ID_PROPERTY) | ||
53 | + private UUID customerId; | ||
54 | + | ||
55 | + @Column(name = ModelConstants.USER_AUTHORITY_PROPERTY) | ||
56 | + private Authority authority; | ||
57 | + | ||
58 | + @Column(name = ModelConstants.USER_EMAIL_PROPERTY) | ||
59 | + private String email; | ||
60 | + | ||
61 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
62 | + private String searchText; | ||
63 | + | ||
64 | + @Column(name = ModelConstants.USER_FIRST_NAME_PROPERTY) | ||
65 | + private String firstName; | ||
66 | + | ||
67 | + @Column(name = ModelConstants.USER_LAST_NAME_PROPERTY) | ||
68 | + private String lastName; | ||
69 | + | ||
70 | + @Column(name = ModelConstants.USER_ADDITIONAL_INFO_PROPERTY) | ||
71 | + private JsonNode additionalInfo; | ||
72 | + | ||
73 | + public UserEntity(User user) { | ||
74 | + if (user.getId() != null) { | ||
75 | + this.id = user.getId().getId(); | ||
76 | + } | ||
77 | + this.authority = user.getAuthority(); | ||
78 | + if (user.getTenantId() != null) { | ||
79 | + this.tenantId = user.getTenantId().getId(); | ||
80 | + } | ||
81 | + if (user.getCustomerId() != null) { | ||
82 | + this.customerId = user.getCustomerId().getId(); | ||
83 | + } | ||
84 | + this.email = user.getEmail(); | ||
85 | + this.firstName = user.getFirstName(); | ||
86 | + this.lastName = user.getLastName(); | ||
87 | + this.additionalInfo = user.getAdditionalInfo(); | ||
88 | + } | ||
89 | + | ||
90 | + public String getSearchText() { | ||
91 | + return searchText; | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public String getSearchTextSource() { | ||
96 | + return searchText; | ||
97 | + } | ||
98 | + | ||
99 | + @Override | ||
100 | + public void setSearchText(String searchText) { | ||
101 | + this.searchText = searchText; | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public UUID getId() { | ||
106 | + return id; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public void setId(UUID id) { | ||
111 | + this.id = id; | ||
112 | + } | ||
113 | + | ||
114 | + public UUID getTenantId() { | ||
115 | + return tenantId; | ||
116 | + } | ||
117 | + | ||
118 | + public void setTenantId(UUID tenantId) { | ||
119 | + this.tenantId = tenantId; | ||
120 | + } | ||
121 | + | ||
122 | + public UUID getCustomerId() { | ||
123 | + return customerId; | ||
124 | + } | ||
125 | + | ||
126 | + public void setCustomerId(UUID customerId) { | ||
127 | + this.customerId = customerId; | ||
128 | + } | ||
129 | + | ||
130 | + public Authority getAuthority() { | ||
131 | + return authority; | ||
132 | + } | ||
133 | + | ||
134 | + public void setAuthority(Authority authority) { | ||
135 | + this.authority = authority; | ||
136 | + } | ||
137 | + | ||
138 | + public String getEmail() { | ||
139 | + return email; | ||
140 | + } | ||
141 | + | ||
142 | + public void setEmail(String email) { | ||
143 | + this.email = email; | ||
144 | + } | ||
145 | + | ||
146 | + public String getFirstName() { | ||
147 | + return firstName; | ||
148 | + } | ||
149 | + | ||
150 | + public void setFirstName(String firstName) { | ||
151 | + this.firstName = firstName; | ||
152 | + } | ||
153 | + | ||
154 | + public String getLastName() { | ||
155 | + return lastName; | ||
156 | + } | ||
157 | + | ||
158 | + public void setLastName(String lastName) { | ||
159 | + this.lastName = lastName; | ||
160 | + } | ||
161 | + | ||
162 | + public JsonNode getAdditionalInfo() { | ||
163 | + return additionalInfo; | ||
164 | + } | ||
165 | + | ||
166 | + public void setAdditionalInfo(JsonNode additionalInfo) { | ||
167 | + this.additionalInfo = additionalInfo; | ||
168 | + } | ||
169 | + | ||
170 | + @Override | ||
171 | + public String toString() { | ||
172 | + StringBuilder builder = new StringBuilder(); | ||
173 | + builder.append("UserEntity [id="); | ||
174 | + builder.append(id); | ||
175 | + builder.append(", authority="); | ||
176 | + builder.append(authority); | ||
177 | + builder.append(", tenantId="); | ||
178 | + builder.append(tenantId); | ||
179 | + builder.append(", customerId="); | ||
180 | + builder.append(customerId); | ||
181 | + builder.append(", email="); | ||
182 | + builder.append(email); | ||
183 | + builder.append(", firstName="); | ||
184 | + builder.append(firstName); | ||
185 | + builder.append(", lastName="); | ||
186 | + builder.append(lastName); | ||
187 | + builder.append(", additionalInfo="); | ||
188 | + builder.append(additionalInfo); | ||
189 | + builder.append("]"); | ||
190 | + return builder.toString(); | ||
191 | + } | ||
192 | + | ||
193 | + @Override | ||
194 | + public User toData() { | ||
195 | + User user = new User(new UserId(id)); | ||
196 | + user.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
197 | + user.setAuthority(authority); | ||
198 | + if (tenantId != null) { | ||
199 | + user.setTenantId(new TenantId(tenantId)); | ||
200 | + } | ||
201 | + if (customerId != null) { | ||
202 | + user.setCustomerId(new CustomerId(customerId)); | ||
203 | + } | ||
204 | + user.setEmail(email); | ||
205 | + user.setFirstName(firstName); | ||
206 | + user.setLastName(lastName); | ||
207 | + user.setAdditionalInfo(additionalInfo); | ||
208 | + return user; | ||
209 | + } | ||
210 | + @Override | ||
211 | + public int hashCode() { | ||
212 | + final int prime = 31; | ||
213 | + int result = 1; | ||
214 | + result = prime * result + ((additionalInfo == null) ? 0 : additionalInfo.hashCode()); | ||
215 | + result = prime * result + ((authority == null) ? 0 : authority.hashCode()); | ||
216 | + result = prime * result + ((customerId == null) ? 0 : customerId.hashCode()); | ||
217 | + result = prime * result + ((email == null) ? 0 : email.hashCode()); | ||
218 | + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); | ||
219 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); | ||
220 | + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); | ||
221 | + result = prime * result + ((tenantId == null) ? 0 : tenantId.hashCode()); | ||
222 | + return result; | ||
223 | + } | ||
224 | + | ||
225 | + @Override | ||
226 | + public boolean equals(Object obj) { | ||
227 | + if (this == obj) | ||
228 | + return true; | ||
229 | + if (obj == null) | ||
230 | + return false; | ||
231 | + if (getClass() != obj.getClass()) | ||
232 | + return false; | ||
233 | + UserEntity other = (UserEntity) obj; | ||
234 | + if (additionalInfo == null) { | ||
235 | + if (other.additionalInfo != null) | ||
236 | + return false; | ||
237 | + } else if (!additionalInfo.equals(other.additionalInfo)) | ||
238 | + return false; | ||
239 | + if (authority != other.authority) | ||
240 | + return false; | ||
241 | + if (customerId == null) { | ||
242 | + if (other.customerId != null) | ||
243 | + return false; | ||
244 | + } else if (!customerId.equals(other.customerId)) | ||
245 | + return false; | ||
246 | + if (email == null) { | ||
247 | + if (other.email != null) | ||
248 | + return false; | ||
249 | + } else if (!email.equals(other.email)) | ||
250 | + return false; | ||
251 | + if (firstName == null) { | ||
252 | + if (other.firstName != null) | ||
253 | + return false; | ||
254 | + } else if (!firstName.equals(other.firstName)) | ||
255 | + return false; | ||
256 | + if (id == null) { | ||
257 | + if (other.id != null) | ||
258 | + return false; | ||
259 | + } else if (!id.equals(other.id)) | ||
260 | + return false; | ||
261 | + if (lastName == null) { | ||
262 | + if (other.lastName != null) | ||
263 | + return false; | ||
264 | + } else if (!lastName.equals(other.lastName)) | ||
265 | + return false; | ||
266 | + if (tenantId == null) { | ||
267 | + if (other.tenantId != null) | ||
268 | + return false; | ||
269 | + } else if (!tenantId.equals(other.tenantId)) | ||
270 | + return false; | ||
271 | + return true; | ||
272 | + } | ||
273 | + | ||
274 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | +import com.datastax.driver.core.utils.UUIDs; | ||
19 | +import javax.persistence.Column; | ||
20 | +import javax.persistence.Entity; | ||
21 | +import javax.persistence.Id; | ||
22 | +import javax.persistence.Table; | ||
23 | +import javax.persistence.Transient; | ||
24 | + | ||
25 | +import com.datastax.driver.mapping.annotations.PartitionKey; | ||
26 | +import com.fasterxml.jackson.databind.JsonNode; | ||
27 | +import org.thingsboard.server.common.data.id.TenantId; | ||
28 | +import org.thingsboard.server.common.data.id.WidgetTypeId; | ||
29 | +import org.thingsboard.server.common.data.widget.WidgetType; | ||
30 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
31 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
32 | + | ||
33 | +import java.util.UUID; | ||
34 | + | ||
35 | +@Entity | ||
36 | +@Table(name = ModelConstants.WIDGET_TYPE_COLUMN_FAMILY_NAME) | ||
37 | +public final class WidgetTypeEntity implements BaseEntity<WidgetType> { | ||
38 | + | ||
39 | + @Transient | ||
40 | + private static final long serialVersionUID = -5436279069884988630L; | ||
41 | + | ||
42 | + @Id | ||
43 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
44 | + private UUID id; | ||
45 | + | ||
46 | + @PartitionKey(value = 1) | ||
47 | + @Column(name = ModelConstants.WIDGET_TYPE_TENANT_ID_PROPERTY) | ||
48 | + private UUID tenantId; | ||
49 | + | ||
50 | + @PartitionKey(value = 2) | ||
51 | + @Column(name = ModelConstants.WIDGET_TYPE_BUNDLE_ALIAS_PROPERTY) | ||
52 | + private String bundleAlias; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.WIDGET_TYPE_ALIAS_PROPERTY) | ||
55 | + private String alias; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.WIDGET_TYPE_NAME_PROPERTY) | ||
58 | + private String name; | ||
59 | + | ||
60 | + @Column(name = ModelConstants.WIDGET_TYPE_DESCRIPTOR_PROPERTY) | ||
61 | + private JsonNode descriptor; | ||
62 | + | ||
63 | + public WidgetTypeEntity() { | ||
64 | + super(); | ||
65 | + } | ||
66 | + | ||
67 | + public WidgetTypeEntity(WidgetType widgetType) { | ||
68 | + if (widgetType.getId() != null) { | ||
69 | + this.id = widgetType.getId().getId(); | ||
70 | + } | ||
71 | + if (widgetType.getTenantId() != null) { | ||
72 | + this.tenantId = widgetType.getTenantId().getId(); | ||
73 | + } | ||
74 | + this.bundleAlias = widgetType.getBundleAlias(); | ||
75 | + this.alias = widgetType.getAlias(); | ||
76 | + this.name = widgetType.getName(); | ||
77 | + this.descriptor = widgetType.getDescriptor(); | ||
78 | + } | ||
79 | + | ||
80 | + @Override | ||
81 | + public UUID getId() { | ||
82 | + return id; | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public void setId(UUID id) { | ||
87 | + this.id = id; | ||
88 | + } | ||
89 | + | ||
90 | + public UUID getTenantId() { | ||
91 | + return tenantId; | ||
92 | + } | ||
93 | + | ||
94 | + public void setTenantId(UUID tenantId) { | ||
95 | + this.tenantId = tenantId; | ||
96 | + } | ||
97 | + | ||
98 | + public String getBundleAlias() { | ||
99 | + return bundleAlias; | ||
100 | + } | ||
101 | + | ||
102 | + public void setBundleAlias(String bundleAlias) { | ||
103 | + this.bundleAlias = bundleAlias; | ||
104 | + } | ||
105 | + | ||
106 | + public String getAlias() { | ||
107 | + return alias; | ||
108 | + } | ||
109 | + | ||
110 | + public void setAlias(String alias) { | ||
111 | + this.alias = alias; | ||
112 | + } | ||
113 | + | ||
114 | + public String getName() { | ||
115 | + return name; | ||
116 | + } | ||
117 | + | ||
118 | + public void setName(String name) { | ||
119 | + this.name = name; | ||
120 | + } | ||
121 | + | ||
122 | + public JsonNode getDescriptor() { | ||
123 | + return descriptor; | ||
124 | + } | ||
125 | + | ||
126 | + public void setDescriptor(JsonNode descriptor) { | ||
127 | + this.descriptor = descriptor; | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public int hashCode() { | ||
132 | + int result = id != null ? id.hashCode() : 0; | ||
133 | + result = 31 * result + (tenantId != null ? tenantId.hashCode() : 0); | ||
134 | + result = 31 * result + (bundleAlias != null ? bundleAlias.hashCode() : 0); | ||
135 | + result = 31 * result + (alias != null ? alias.hashCode() : 0); | ||
136 | + result = 31 * result + (name != null ? name.hashCode() : 0); | ||
137 | + result = 31 * result + (descriptor != null ? descriptor.hashCode() : 0); | ||
138 | + return result; | ||
139 | + } | ||
140 | + | ||
141 | + @Override | ||
142 | + public boolean equals(Object o) { | ||
143 | + if (this == o) return true; | ||
144 | + if (o == null || getClass() != o.getClass()) return false; | ||
145 | + | ||
146 | + WidgetTypeEntity that = (WidgetTypeEntity) o; | ||
147 | + | ||
148 | + if (id != null ? !id.equals(that.id) : that.id != null) return false; | ||
149 | + if (tenantId != null ? !tenantId.equals(that.tenantId) : that.tenantId != null) return false; | ||
150 | + if (bundleAlias != null ? !bundleAlias.equals(that.bundleAlias) : that.bundleAlias != null) return false; | ||
151 | + if (alias != null ? !alias.equals(that.alias) : that.alias != null) return false; | ||
152 | + if (name != null ? !name.equals(that.name) : that.name != null) return false; | ||
153 | + return descriptor != null ? descriptor.equals(that.descriptor) : that.descriptor == null; | ||
154 | + } | ||
155 | + | ||
156 | + @Override | ||
157 | + public String toString() { | ||
158 | + final StringBuilder sb = new StringBuilder("WidgetTypeEntity{"); | ||
159 | + sb.append("id=").append(id); | ||
160 | + sb.append(", tenantId=").append(tenantId); | ||
161 | + sb.append(", bundleAlias='").append(bundleAlias).append('\''); | ||
162 | + sb.append(", alias='").append(alias).append('\''); | ||
163 | + sb.append(", name='").append(name).append('\''); | ||
164 | + sb.append(", descriptor=").append(descriptor); | ||
165 | + sb.append('}'); | ||
166 | + return sb.toString(); | ||
167 | + } | ||
168 | + | ||
169 | + @Override | ||
170 | + public WidgetType toData() { | ||
171 | + WidgetType widgetType = new WidgetType(new WidgetTypeId(id)); | ||
172 | + widgetType.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
173 | + if (tenantId != null) { | ||
174 | + widgetType.setTenantId(new TenantId(tenantId)); | ||
175 | + } | ||
176 | + widgetType.setBundleAlias(bundleAlias); | ||
177 | + widgetType.setAlias(alias); | ||
178 | + widgetType.setName(name); | ||
179 | + widgetType.setDescriptor(descriptor); | ||
180 | + return widgetType; | ||
181 | + } | ||
182 | + | ||
183 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.model.sql; | ||
17 | + | ||
18 | + | ||
19 | +import com.datastax.driver.core.utils.UUIDs; | ||
20 | +import javax.persistence.Column; | ||
21 | +import javax.persistence.Entity; | ||
22 | +import javax.persistence.Id; | ||
23 | +import javax.persistence.Table; | ||
24 | +import javax.persistence.Transient; | ||
25 | +import org.thingsboard.server.common.data.id.TenantId; | ||
26 | +import org.thingsboard.server.common.data.id.WidgetsBundleId; | ||
27 | +import org.thingsboard.server.common.data.widget.WidgetsBundle; | ||
28 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
29 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
30 | + | ||
31 | +import java.nio.ByteBuffer; | ||
32 | +import java.util.UUID; | ||
33 | + | ||
34 | +@Entity | ||
35 | +@Table(name = ModelConstants.WIDGETS_BUNDLE_COLUMN_FAMILY_NAME) | ||
36 | +public final class WidgetsBundleEntity implements SearchTextEntity<WidgetsBundle> { | ||
37 | + | ||
38 | + @Transient | ||
39 | + private static final long serialVersionUID = 6897035686422298096L; | ||
40 | + | ||
41 | + @Id | ||
42 | + @Column(name = ModelConstants.ID_PROPERTY) | ||
43 | + private UUID id; | ||
44 | + | ||
45 | + @Column(name = ModelConstants.WIDGETS_BUNDLE_TENANT_ID_PROPERTY) | ||
46 | + private UUID tenantId; | ||
47 | + | ||
48 | + @Column(name = ModelConstants.WIDGETS_BUNDLE_ALIAS_PROPERTY) | ||
49 | + private String alias; | ||
50 | + | ||
51 | + @Column(name = ModelConstants.WIDGETS_BUNDLE_TITLE_PROPERTY) | ||
52 | + private String title; | ||
53 | + | ||
54 | + @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) | ||
55 | + private String searchText; | ||
56 | + | ||
57 | + @Column(name = ModelConstants.WIDGETS_BUNDLE_IMAGE_PROPERTY) | ||
58 | + private ByteBuffer image; | ||
59 | + | ||
60 | + public WidgetsBundleEntity() { | ||
61 | + super(); | ||
62 | + } | ||
63 | + | ||
64 | + public WidgetsBundleEntity(WidgetsBundle widgetsBundle) { | ||
65 | + if (widgetsBundle.getId() != null) { | ||
66 | + this.id = widgetsBundle.getId().getId(); | ||
67 | + } | ||
68 | + if (widgetsBundle.getTenantId() != null) { | ||
69 | + this.tenantId = widgetsBundle.getTenantId().getId(); | ||
70 | + } | ||
71 | + this.alias = widgetsBundle.getAlias(); | ||
72 | + this.title = widgetsBundle.getTitle(); | ||
73 | + if (widgetsBundle.getImage() != null) { | ||
74 | + this.image = ByteBuffer.wrap(widgetsBundle.getImage()); | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public UUID getId() { | ||
80 | + return id; | ||
81 | + } | ||
82 | + | ||
83 | + @Override | ||
84 | + public void setId(UUID id) { | ||
85 | + this.id = id; | ||
86 | + } | ||
87 | + | ||
88 | + public UUID getTenantId() { | ||
89 | + return tenantId; | ||
90 | + } | ||
91 | + | ||
92 | + public void setTenantId(UUID tenantId) { | ||
93 | + this.tenantId = tenantId; | ||
94 | + } | ||
95 | + | ||
96 | + public String getAlias() { | ||
97 | + return alias; | ||
98 | + } | ||
99 | + | ||
100 | + public void setAlias(String alias) { | ||
101 | + this.alias = alias; | ||
102 | + } | ||
103 | + | ||
104 | + public String getTitle() { | ||
105 | + return title; | ||
106 | + } | ||
107 | + | ||
108 | + public void setTitle(String title) { | ||
109 | + this.title = title; | ||
110 | + } | ||
111 | + | ||
112 | + public ByteBuffer getImage() { | ||
113 | + return image; | ||
114 | + } | ||
115 | + | ||
116 | + public void setImage(ByteBuffer image) { | ||
117 | + this.image = image; | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
121 | + public String getSearchTextSource() { | ||
122 | + return title; | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public void setSearchText(String searchText) { | ||
127 | + this.searchText = searchText; | ||
128 | + } | ||
129 | + | ||
130 | + public String getSearchText() { | ||
131 | + return searchText; | ||
132 | + } | ||
133 | + | ||
134 | + @Override | ||
135 | + public int hashCode() { | ||
136 | + int result = id != null ? id.hashCode() : 0; | ||
137 | + result = 31 * result + (tenantId != null ? tenantId.hashCode() : 0); | ||
138 | + result = 31 * result + (alias != null ? alias.hashCode() : 0); | ||
139 | + result = 31 * result + (title != null ? title.hashCode() : 0); | ||
140 | + result = 31 * result + (searchText != null ? searchText.hashCode() : 0); | ||
141 | + result = 31 * result + (image != null ? image.hashCode() : 0); | ||
142 | + return result; | ||
143 | + } | ||
144 | + | ||
145 | + @Override | ||
146 | + public boolean equals(Object o) { | ||
147 | + if (this == o) return true; | ||
148 | + if (o == null || getClass() != o.getClass()) return false; | ||
149 | + | ||
150 | + WidgetsBundleEntity that = (WidgetsBundleEntity) o; | ||
151 | + | ||
152 | + if (id != null ? !id.equals(that.id) : that.id != null) return false; | ||
153 | + if (tenantId != null ? !tenantId.equals(that.tenantId) : that.tenantId != null) return false; | ||
154 | + if (alias != null ? !alias.equals(that.alias) : that.alias != null) return false; | ||
155 | + if (title != null ? !title.equals(that.title) : that.title != null) return false; | ||
156 | + if (searchText != null ? !searchText.equals(that.searchText) : that.searchText != null) return false; | ||
157 | + return image != null ? image.equals(that.image) : that.image == null; | ||
158 | + | ||
159 | + } | ||
160 | + | ||
161 | + @Override | ||
162 | + public String toString() { | ||
163 | + final StringBuilder sb = new StringBuilder("WidgetsBundleEntity{"); | ||
164 | + sb.append("id=").append(id); | ||
165 | + sb.append(", tenantId=").append(tenantId); | ||
166 | + sb.append(", alias='").append(alias).append('\''); | ||
167 | + sb.append(", title='").append(title).append('\''); | ||
168 | + sb.append(", searchText='").append(searchText).append('\''); | ||
169 | + sb.append(", image=").append(image); | ||
170 | + sb.append('}'); | ||
171 | + return sb.toString(); | ||
172 | + } | ||
173 | + | ||
174 | + @Override | ||
175 | + public WidgetsBundle toData() { | ||
176 | + WidgetsBundle widgetsBundle = new WidgetsBundle(new WidgetsBundleId(id)); | ||
177 | + widgetsBundle.setCreatedTime(UUIDs.unixTimestamp(id)); | ||
178 | + if (tenantId != null) { | ||
179 | + widgetsBundle.setTenantId(new TenantId(tenantId)); | ||
180 | + } | ||
181 | + widgetsBundle.setAlias(alias); | ||
182 | + widgetsBundle.setTitle(title); | ||
183 | + if (image != null) { | ||
184 | + byte[] imageByteArray = new byte[image.remaining()]; | ||
185 | + image.get(imageByteArray); | ||
186 | + widgetsBundle.setImage(imageByteArray); | ||
187 | + } | ||
188 | + return widgetsBundle; | ||
189 | + } | ||
190 | +} |
@@ -25,7 +25,7 @@ import org.thingsboard.server.common.data.plugin.PluginMetaData; | @@ -25,7 +25,7 @@ import org.thingsboard.server.common.data.plugin.PluginMetaData; | ||
25 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 25 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
26 | import org.thingsboard.server.dao.DaoUtil; | 26 | import org.thingsboard.server.dao.DaoUtil; |
27 | import org.thingsboard.server.dao.model.ModelConstants; | 27 | import org.thingsboard.server.dao.model.ModelConstants; |
28 | -import org.thingsboard.server.dao.model.PluginMetaDataEntity; | 28 | +import org.thingsboard.server.dao.model.nosql.PluginMetaDataEntity; |
29 | 29 | ||
30 | import java.util.Arrays; | 30 | import java.util.Arrays; |
31 | import java.util.List; | 31 | import java.util.List; |
@@ -25,7 +25,7 @@ import org.thingsboard.server.common.data.rule.RuleMetaData; | @@ -25,7 +25,7 @@ import org.thingsboard.server.common.data.rule.RuleMetaData; | ||
25 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 25 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
26 | import org.thingsboard.server.dao.DaoUtil; | 26 | import org.thingsboard.server.dao.DaoUtil; |
27 | import org.thingsboard.server.dao.model.ModelConstants; | 27 | import org.thingsboard.server.dao.model.ModelConstants; |
28 | -import org.thingsboard.server.dao.model.RuleMetaDataEntity; | 28 | +import org.thingsboard.server.dao.model.nosql.RuleMetaDataEntity; |
29 | 29 | ||
30 | import java.util.Arrays; | 30 | import java.util.Arrays; |
31 | import java.util.List; | 31 | import java.util.List; |
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | ||
21 | import org.thingsboard.server.common.data.AdminSettings; | 21 | import org.thingsboard.server.common.data.AdminSettings; |
22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.AdminSettingsEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.AdminSettingsEntity; |
25 | 25 | ||
26 | import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; | 26 | import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; |
27 | import static com.datastax.driver.core.querybuilder.QueryBuilder.select; | 27 | import static com.datastax.driver.core.querybuilder.QueryBuilder.select; |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.sql; | ||
17 | + | ||
18 | +import com.google.common.collect.Lists; | ||
19 | +import com.google.common.util.concurrent.ListenableFuture; | ||
20 | +import lombok.extern.slf4j.Slf4j; | ||
21 | +import org.thingsboard.server.dao.Dao; | ||
22 | +import org.thingsboard.server.dao.DaoUtil; | ||
23 | +import org.thingsboard.server.dao.model.BaseEntity; | ||
24 | +import org.thingsboard.server.dao.model.SearchTextEntity; | ||
25 | +import org.thingsboard.server.dao.sql.user.JpaRepository; | ||
26 | + | ||
27 | +import java.util.List; | ||
28 | +import java.util.UUID; | ||
29 | + | ||
30 | +/** | ||
31 | + * @author Valerii Sosliuk | ||
32 | + */ | ||
33 | +@Slf4j | ||
34 | +public abstract class JpaAbstractDao<E extends BaseEntity<D>, D> implements Dao<D> { | ||
35 | + | ||
36 | + protected abstract Class<E> getColumnFamilyClass(); | ||
37 | + | ||
38 | + protected abstract String getColumnFamilyName(); | ||
39 | + | ||
40 | + protected abstract JpaRepository<E, UUID> getCrudRepository(); | ||
41 | + | ||
42 | + protected boolean isSearchTextDao() { | ||
43 | + return false; | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public D save(D domain) { | ||
48 | + E entity; | ||
49 | + try { | ||
50 | + entity = getColumnFamilyClass().getConstructor(domain.getClass()).newInstance(domain); | ||
51 | + } catch (Exception e) { | ||
52 | + log.error("Can't create entity for domain object {}", domain, e); | ||
53 | + throw new IllegalArgumentException("Can't create entity for domain object {" + domain + "}", e); | ||
54 | + } if (isSearchTextDao()) { | ||
55 | + ((SearchTextEntity) entity).setSearchText(((SearchTextEntity) entity).getSearchTextSource().toLowerCase()); | ||
56 | + } | ||
57 | + log.debug("Saving entity {}", entity); | ||
58 | + entity = getCrudRepository().save(entity); | ||
59 | + return DaoUtil.getData(entity); | ||
60 | + } | ||
61 | + | ||
62 | + @Override | ||
63 | + public D findById(UUID key) { | ||
64 | + log.debug("Get entity by key {}", key); | ||
65 | + E entity = getCrudRepository().findOne(key); | ||
66 | + return DaoUtil.getData(entity); | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public ListenableFuture<D> findByIdAsync(UUID key) { | ||
71 | + log.debug("Get entity by key {}", key); | ||
72 | + org.springframework.util.concurrent.ListenableFuture<E> entityFuture = getCrudRepository().findByIdAsync(key); | ||
73 | + // TODO: vsosliuk implement | ||
74 | + return null; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public boolean removeById(UUID key) { | ||
79 | + getCrudRepository().delete(key); | ||
80 | + log.debug("Remove request: {}", key); | ||
81 | + return getCrudRepository().equals(key); | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public List<D> find() { | ||
86 | + log.debug("Get all entities from column family {}", getColumnFamilyName()); | ||
87 | + List<E> entities = Lists.newArrayList(getCrudRepository().findAll()); | ||
88 | + return DaoUtil.convertDataList(entities); | ||
89 | + } | ||
90 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.sql.user; | ||
17 | + | ||
18 | +import org.springframework.data.repository.CrudRepository; | ||
19 | +import org.springframework.scheduling.annotation.Async; | ||
20 | +import org.springframework.util.concurrent.ListenableFuture; | ||
21 | + | ||
22 | +import java.io.Serializable; | ||
23 | + | ||
24 | +/** | ||
25 | + * @author Valerii Sosliuk | ||
26 | + */ | ||
27 | +public interface JpaRepository<E, ID extends Serializable> extends CrudRepository<E, ID> { | ||
28 | + | ||
29 | + @Async | ||
30 | + ListenableFuture<E> findByIdAsync(ID key); | ||
31 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.sql.user; | ||
17 | + | ||
18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
19 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
20 | +import org.springframework.stereotype.Component; | ||
21 | +import org.thingsboard.server.common.data.User; | ||
22 | +import org.thingsboard.server.dao.model.ModelConstants; | ||
23 | +import org.thingsboard.server.dao.model.sql.UserEntity; | ||
24 | +import org.thingsboard.server.dao.sql.JpaAbstractDao; | ||
25 | + | ||
26 | +import java.util.UUID; | ||
27 | + | ||
28 | +/** | ||
29 | + * @author Valerii Sosliuk | ||
30 | + */ | ||
31 | +@Component | ||
32 | +@ConditionalOnProperty(prefix="sql", value="enabled",havingValue = "true", matchIfMissing = false) | ||
33 | +public class JpaUserDao extends JpaAbstractDao<UserEntity, User> { | ||
34 | + | ||
35 | + @Autowired | ||
36 | + private UserRepository userRepository; | ||
37 | + | ||
38 | + @Override | ||
39 | + protected Class<UserEntity> getColumnFamilyClass() { | ||
40 | + return UserEntity.class; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + protected String getColumnFamilyName() { | ||
45 | + return ModelConstants.USER_COLUMN_FAMILY_NAME; | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + protected JpaRepository<UserEntity, UUID> getCrudRepository() { | ||
50 | + return userRepository; | ||
51 | + } | ||
52 | +} |
1 | +/** | ||
2 | + * Copyright © 2016-2017 The Thingsboard Authors | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (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 | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.thingsboard.server.dao.sql.user; | ||
17 | + | ||
18 | +import org.thingsboard.server.dao.model.sql.UserEntity; | ||
19 | + | ||
20 | +import java.util.UUID; | ||
21 | + | ||
22 | +/** | ||
23 | + * @author Valerii Sosliuk | ||
24 | + */ | ||
25 | +public interface UserRepository extends JpaRepository<UserEntity, UUID> { | ||
26 | +} |
@@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.Tenant; | @@ -21,7 +21,7 @@ import org.thingsboard.server.common.data.Tenant; | ||
21 | import org.thingsboard.server.common.data.page.TextPageLink; | 21 | import org.thingsboard.server.common.data.page.TextPageLink; |
22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.TenantEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.TenantEntity; |
25 | 25 | ||
26 | import java.util.Arrays; | 26 | import java.util.Arrays; |
27 | import java.util.List; | 27 | import java.util.List; |
@@ -22,7 +22,7 @@ import org.thingsboard.server.common.data.security.UserCredentials; | @@ -22,7 +22,7 @@ import org.thingsboard.server.common.data.security.UserCredentials; | ||
22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | import org.thingsboard.server.dao.model.ModelConstants; | 24 | import org.thingsboard.server.dao.model.ModelConstants; |
25 | -import org.thingsboard.server.dao.model.UserCredentialsEntity; | 25 | +import org.thingsboard.server.dao.model.nosql.UserCredentialsEntity; |
26 | 26 | ||
27 | import java.util.UUID; | 27 | import java.util.UUID; |
28 | 28 |
@@ -24,7 +24,7 @@ import org.thingsboard.server.common.data.security.Authority; | @@ -24,7 +24,7 @@ import org.thingsboard.server.common.data.security.Authority; | ||
24 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 24 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
25 | import org.thingsboard.server.dao.DaoUtil; | 25 | import org.thingsboard.server.dao.DaoUtil; |
26 | import org.thingsboard.server.dao.model.ModelConstants; | 26 | import org.thingsboard.server.dao.model.ModelConstants; |
27 | -import org.thingsboard.server.dao.model.UserEntity; | 27 | +import org.thingsboard.server.dao.model.nosql.UserEntity; |
28 | 28 | ||
29 | import java.util.Arrays; | 29 | import java.util.Arrays; |
30 | import java.util.List; | 30 | import java.util.List; |
@@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | @@ -21,7 +21,7 @@ import org.springframework.stereotype.Component; | ||
21 | import org.thingsboard.server.common.data.widget.WidgetType; | 21 | import org.thingsboard.server.common.data.widget.WidgetType; |
22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; | 22 | import org.thingsboard.server.dao.CassandraAbstractModelDao; |
23 | import org.thingsboard.server.dao.DaoUtil; | 23 | import org.thingsboard.server.dao.DaoUtil; |
24 | -import org.thingsboard.server.dao.model.WidgetTypeEntity; | 24 | +import org.thingsboard.server.dao.model.nosql.WidgetTypeEntity; |
25 | 25 | ||
26 | import java.util.List; | 26 | import java.util.List; |
27 | import java.util.UUID; | 27 | import java.util.UUID; |
@@ -22,7 +22,7 @@ import org.thingsboard.server.common.data.page.TextPageLink; | @@ -22,7 +22,7 @@ import org.thingsboard.server.common.data.page.TextPageLink; | ||
22 | import org.thingsboard.server.common.data.widget.WidgetsBundle; | 22 | import org.thingsboard.server.common.data.widget.WidgetsBundle; |
23 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; | 23 | import org.thingsboard.server.dao.CassandraAbstractSearchTextDao; |
24 | import org.thingsboard.server.dao.DaoUtil; | 24 | import org.thingsboard.server.dao.DaoUtil; |
25 | -import org.thingsboard.server.dao.model.WidgetsBundleEntity; | 25 | +import org.thingsboard.server.dao.model.nosql.WidgetsBundleEntity; |
26 | 26 | ||
27 | import java.util.Arrays; | 27 | import java.util.Arrays; |
28 | import java.util.List; | 28 | import java.util.List; |
@@ -24,6 +24,8 @@ import org.thingsboard.server.common.data.page.TextPageLink; | @@ -24,6 +24,8 @@ import org.thingsboard.server.common.data.page.TextPageLink; | ||
24 | import org.thingsboard.server.common.data.plugin.PluginMetaData; | 24 | import org.thingsboard.server.common.data.plugin.PluginMetaData; |
25 | import org.thingsboard.server.dao.model.ModelConstants; | 25 | import org.thingsboard.server.dao.model.ModelConstants; |
26 | import org.thingsboard.server.dao.service.AbstractServiceTest; | 26 | import org.thingsboard.server.dao.service.AbstractServiceTest; |
27 | +import org.junit.Assert; | ||
28 | +import org.junit.Test; | ||
27 | 29 | ||
28 | import java.util.UUID; | 30 | import java.util.UUID; |
29 | 31 |
@@ -412,6 +412,11 @@ | @@ -412,6 +412,11 @@ | ||
412 | <scope>test</scope> | 412 | <scope>test</scope> |
413 | </dependency> | 413 | </dependency> |
414 | <dependency> | 414 | <dependency> |
415 | + <groupId>org.springframework.boot</groupId> | ||
416 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | ||
417 | + <version>${spring-boot.version}</version> | ||
418 | + </dependency> | ||
419 | + <dependency> | ||
415 | <groupId>org.springframework</groupId> | 420 | <groupId>org.springframework</groupId> |
416 | <artifactId>spring-context</artifactId> | 421 | <artifactId>spring-context</artifactId> |
417 | <version>${spring.version}</version> | 422 | <version>${spring.version}</version> |