Showing
12 changed files
with
81 additions
and
11 deletions
1 | +-- | |
2 | +-- Copyright © 2016-2019 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 | + | |
17 | +ALTER TABLE device ADD label text; | ... | ... |
1 | +-- | |
2 | +-- Copyright © 2016-2019 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 | + | |
17 | +ALTER TABLE device ADD COLUMN label varchar(255); | ... | ... |
... | ... | @@ -111,6 +111,12 @@ public class ThingsboardInstallService { |
111 | 111 | |
112 | 112 | databaseUpgradeService.upgradeDatabase("2.3.0"); |
113 | 113 | |
114 | + break; | |
115 | + case "2.3.1": | |
116 | + log.info("Upgrading ThingsBoard from version 2.3.1 to 2.4.0 ..."); | |
117 | + | |
118 | + databaseUpgradeService.upgradeDatabase("2.3.1"); | |
119 | + | |
114 | 120 | log.info("Updating system data..."); |
115 | 121 | |
116 | 122 | systemDataLoaderService.deleteSystemWidgetBundle("charts"); |
... | ... | @@ -127,7 +133,6 @@ public class ThingsboardInstallService { |
127 | 133 | systemDataLoaderService.deleteSystemWidgetBundle("date"); |
128 | 134 | |
129 | 135 | systemDataLoaderService.loadSystemWidgets(); |
130 | - break; | |
131 | 136 | default: |
132 | 137 | throw new RuntimeException("Unable to upgrade ThingsBoard, unsupported fromVersion: " + upgradeFromVersion); |
133 | 138 | ... | ... |
... | ... | @@ -257,6 +257,12 @@ public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService { |
257 | 257 | break; |
258 | 258 | case "2.3.0": |
259 | 259 | break; |
260 | + case "2.3.1": | |
261 | + log.info("Updating schema ..."); | |
262 | + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_CQL); | |
263 | + loadCql(schemaUpdateFile); | |
264 | + log.info("Schema updated."); | |
265 | + break; | |
260 | 266 | default: |
261 | 267 | throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion); |
262 | 268 | } | ... | ... |
... | ... | @@ -165,6 +165,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService { |
165 | 165 | log.info("Schema updated."); |
166 | 166 | } |
167 | 167 | break; |
168 | + case "2.3.1": | |
169 | + try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) { | |
170 | + log.info("Updating schema ..."); | |
171 | + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.0", SCHEMA_UPDATE_SQL); | |
172 | + loadSql(schemaUpdateFile, conn); | |
173 | + log.info("Schema updated."); | |
174 | + } | |
175 | + break; | |
168 | 176 | default: |
169 | 177 | throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion); |
170 | 178 | } | ... | ... |
... | ... | @@ -20,8 +20,6 @@ import org.thingsboard.server.common.data.id.CustomerId; |
20 | 20 | import org.thingsboard.server.common.data.id.DeviceId; |
21 | 21 | import org.thingsboard.server.common.data.id.TenantId; |
22 | 22 | |
23 | -import com.fasterxml.jackson.databind.JsonNode; | |
24 | - | |
25 | 23 | @EqualsAndHashCode(callSuper = true) |
26 | 24 | public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implements HasName, HasTenantId, HasCustomerId { |
27 | 25 | |
... | ... | @@ -31,6 +29,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen |
31 | 29 | private CustomerId customerId; |
32 | 30 | private String name; |
33 | 31 | private String type; |
32 | + private String label; | |
34 | 33 | |
35 | 34 | public Device() { |
36 | 35 | super(); |
... | ... | @@ -46,6 +45,7 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen |
46 | 45 | this.customerId = device.getCustomerId(); |
47 | 46 | this.name = device.getName(); |
48 | 47 | this.type = device.getType(); |
48 | + this.label = device.getLabel(); | |
49 | 49 | } |
50 | 50 | |
51 | 51 | public TenantId getTenantId() { |
... | ... | @@ -81,6 +81,14 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen |
81 | 81 | this.type = type; |
82 | 82 | } |
83 | 83 | |
84 | + public String getLabel() { | |
85 | + return label; | |
86 | + } | |
87 | + | |
88 | + public void setLabel(String label) { | |
89 | + this.label = label; | |
90 | + } | |
91 | + | |
84 | 92 | @Override |
85 | 93 | public String getSearchText() { |
86 | 94 | return getName(); |
... | ... | @@ -97,6 +105,8 @@ public class Device extends SearchTextBasedWithAdditionalInfo<DeviceId> implemen |
97 | 105 | builder.append(name); |
98 | 106 | builder.append(", type="); |
99 | 107 | builder.append(type); |
108 | + builder.append(", label="); | |
109 | + builder.append(label); | |
100 | 110 | builder.append(", additionalInfo="); |
101 | 111 | builder.append(getAdditionalInfo()); |
102 | 112 | builder.append(", createdTime="); | ... | ... |
... | ... | @@ -134,6 +134,7 @@ public class ModelConstants { |
134 | 134 | public static final String DEVICE_CUSTOMER_ID_PROPERTY = CUSTOMER_ID_PROPERTY; |
135 | 135 | public static final String DEVICE_NAME_PROPERTY = "name"; |
136 | 136 | public static final String DEVICE_TYPE_PROPERTY = "type"; |
137 | + public static final String DEVICE_LABEL_PROPERTY = "label"; | |
137 | 138 | public static final String DEVICE_ADDITIONAL_INFO_PROPERTY = ADDITIONAL_INFO_PROPERTY; |
138 | 139 | public static final String DEVICE_BY_TENANT_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_and_search_text"; |
139 | 140 | public static final String DEVICE_BY_TENANT_BY_TYPE_AND_SEARCH_TEXT_COLUMN_FAMILY_NAME = "device_by_tenant_by_type_and_search_text"; | ... | ... |
... | ... | @@ -31,14 +31,7 @@ import org.thingsboard.server.dao.model.type.JsonCodec; |
31 | 31 | |
32 | 32 | import java.util.UUID; |
33 | 33 | |
34 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_ADDITIONAL_INFO_PROPERTY; | |
35 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_COLUMN_FAMILY_NAME; | |
36 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_CUSTOMER_ID_PROPERTY; | |
37 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_NAME_PROPERTY; | |
38 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TENANT_ID_PROPERTY; | |
39 | -import static org.thingsboard.server.dao.model.ModelConstants.DEVICE_TYPE_PROPERTY; | |
40 | -import static org.thingsboard.server.dao.model.ModelConstants.ID_PROPERTY; | |
41 | -import static org.thingsboard.server.dao.model.ModelConstants.SEARCH_TEXT_PROPERTY; | |
34 | +import static org.thingsboard.server.dao.model.ModelConstants.*; | |
42 | 35 | |
43 | 36 | @Table(name = DEVICE_COLUMN_FAMILY_NAME) |
44 | 37 | @EqualsAndHashCode |
... | ... | @@ -64,6 +57,9 @@ public final class DeviceEntity implements SearchTextEntity<Device> { |
64 | 57 | @Column(name = DEVICE_NAME_PROPERTY) |
65 | 58 | private String name; |
66 | 59 | |
60 | + @Column(name = DEVICE_LABEL_PROPERTY) | |
61 | + private String label; | |
62 | + | |
67 | 63 | @Column(name = SEARCH_TEXT_PROPERTY) |
68 | 64 | private String searchText; |
69 | 65 | |
... | ... | @@ -86,6 +82,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> { |
86 | 82 | } |
87 | 83 | this.name = device.getName(); |
88 | 84 | this.type = device.getType(); |
85 | + this.label = device.getLabel(); | |
89 | 86 | this.additionalInfo = device.getAdditionalInfo(); |
90 | 87 | } |
91 | 88 | |
... | ... | @@ -163,6 +160,7 @@ public final class DeviceEntity implements SearchTextEntity<Device> { |
163 | 160 | } |
164 | 161 | device.setName(name); |
165 | 162 | device.setType(type); |
163 | + device.setLabel(label); | |
166 | 164 | device.setAdditionalInfo(additionalInfo); |
167 | 165 | return device; |
168 | 166 | } | ... | ... |
... | ... | @@ -53,6 +53,9 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT |
53 | 53 | @Column(name = ModelConstants.DEVICE_NAME_PROPERTY) |
54 | 54 | private String name; |
55 | 55 | |
56 | + @Column(name = ModelConstants.DEVICE_LABEL_PROPERTY) | |
57 | + private String label; | |
58 | + | |
56 | 59 | @Column(name = ModelConstants.SEARCH_TEXT_PROPERTY) |
57 | 60 | private String searchText; |
58 | 61 | |
... | ... | @@ -76,6 +79,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT |
76 | 79 | } |
77 | 80 | this.name = device.getName(); |
78 | 81 | this.type = device.getType(); |
82 | + this.label = device.getLabel(); | |
79 | 83 | this.additionalInfo = device.getAdditionalInfo(); |
80 | 84 | } |
81 | 85 | |
... | ... | @@ -101,6 +105,7 @@ public final class DeviceEntity extends BaseSqlEntity<Device> implements SearchT |
101 | 105 | } |
102 | 106 | device.setName(name); |
103 | 107 | device.setType(type); |
108 | + device.setLabel(label); | |
104 | 109 | device.setAdditionalInfo(additionalInfo); |
105 | 110 | return device; |
106 | 111 | } | ... | ... |
... | ... | @@ -347,6 +347,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device |
347 | 347 | return { |
348 | 348 | origEntity: entity, |
349 | 349 | name: entity.name, |
350 | + label: entity.label?entity.label:"", | |
350 | 351 | entityType: entity.id.entityType, |
351 | 352 | id: entity.id.id, |
352 | 353 | entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" | ... | ... |