Showing
25 changed files
with
249 additions
and
37 deletions
@@ -55,12 +55,12 @@ import org.thingsboard.server.service.subscription.TbLocalSubscriptionService; | @@ -55,12 +55,12 @@ import org.thingsboard.server.service.subscription.TbLocalSubscriptionService; | ||
55 | import org.thingsboard.server.service.subscription.TbAttributeSubscriptionScope; | 55 | import org.thingsboard.server.service.subscription.TbAttributeSubscriptionScope; |
56 | import org.thingsboard.server.service.subscription.TbAttributeSubscription; | 56 | import org.thingsboard.server.service.subscription.TbAttributeSubscription; |
57 | import org.thingsboard.server.service.subscription.TbTimeseriesSubscription; | 57 | import org.thingsboard.server.service.subscription.TbTimeseriesSubscription; |
58 | -import org.thingsboard.server.service.telemetry.cmd.AttributesSubscriptionCmd; | ||
59 | -import org.thingsboard.server.service.telemetry.cmd.GetHistoryCmd; | ||
60 | -import org.thingsboard.server.service.telemetry.cmd.SubscriptionCmd; | ||
61 | -import org.thingsboard.server.service.telemetry.cmd.TelemetryPluginCmd; | 58 | +import org.thingsboard.server.service.telemetry.cmd.v1.AttributesSubscriptionCmd; |
59 | +import org.thingsboard.server.service.telemetry.cmd.v1.GetHistoryCmd; | ||
60 | +import org.thingsboard.server.service.telemetry.cmd.v1.SubscriptionCmd; | ||
61 | +import org.thingsboard.server.service.telemetry.cmd.v1.TelemetryPluginCmd; | ||
62 | import org.thingsboard.server.service.telemetry.cmd.TelemetryPluginCmdsWrapper; | 62 | import org.thingsboard.server.service.telemetry.cmd.TelemetryPluginCmdsWrapper; |
63 | -import org.thingsboard.server.service.telemetry.cmd.TimeseriesSubscriptionCmd; | 63 | +import org.thingsboard.server.service.telemetry.cmd.v1.TimeseriesSubscriptionCmd; |
64 | import org.thingsboard.server.service.telemetry.exception.UnauthorizedException; | 64 | import org.thingsboard.server.service.telemetry.exception.UnauthorizedException; |
65 | import org.thingsboard.server.service.telemetry.sub.SubscriptionErrorCode; | 65 | import org.thingsboard.server.service.telemetry.sub.SubscriptionErrorCode; |
66 | import org.thingsboard.server.service.telemetry.sub.SubscriptionUpdate; | 66 | import org.thingsboard.server.service.telemetry.sub.SubscriptionUpdate; |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
7 | * | 7 | * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * | 9 | * |
10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -15,11 +15,19 @@ | @@ -15,11 +15,19 @@ | ||
15 | */ | 15 | */ |
16 | package org.thingsboard.server.service.telemetry.cmd; | 16 | package org.thingsboard.server.service.telemetry.cmd; |
17 | 17 | ||
18 | +import lombok.Data; | ||
19 | +import org.thingsboard.server.service.telemetry.cmd.v1.AttributesSubscriptionCmd; | ||
20 | +import org.thingsboard.server.service.telemetry.cmd.v1.GetHistoryCmd; | ||
21 | +import org.thingsboard.server.service.telemetry.cmd.v1.TimeseriesSubscriptionCmd; | ||
22 | +import org.thingsboard.server.service.telemetry.cmd.v2.EntityDataCmd; | ||
23 | +import org.thingsboard.server.service.telemetry.cmd.v2.EntityDataUnsubscribeCmd; | ||
24 | + | ||
18 | import java.util.List; | 25 | import java.util.List; |
19 | 26 | ||
20 | /** | 27 | /** |
21 | * @author Andrew Shvayka | 28 | * @author Andrew Shvayka |
22 | */ | 29 | */ |
30 | +@Data | ||
23 | public class TelemetryPluginCmdsWrapper { | 31 | public class TelemetryPluginCmdsWrapper { |
24 | 32 | ||
25 | private List<AttributesSubscriptionCmd> attrSubCmds; | 33 | private List<AttributesSubscriptionCmd> attrSubCmds; |
@@ -28,31 +36,8 @@ public class TelemetryPluginCmdsWrapper { | @@ -28,31 +36,8 @@ public class TelemetryPluginCmdsWrapper { | ||
28 | 36 | ||
29 | private List<GetHistoryCmd> historyCmds; | 37 | private List<GetHistoryCmd> historyCmds; |
30 | 38 | ||
31 | - public TelemetryPluginCmdsWrapper() { | ||
32 | - super(); | ||
33 | - } | ||
34 | - | ||
35 | - public List<AttributesSubscriptionCmd> getAttrSubCmds() { | ||
36 | - return attrSubCmds; | ||
37 | - } | ||
38 | - | ||
39 | - public void setAttrSubCmds(List<AttributesSubscriptionCmd> attrSubCmds) { | ||
40 | - this.attrSubCmds = attrSubCmds; | ||
41 | - } | ||
42 | - | ||
43 | - public List<TimeseriesSubscriptionCmd> getTsSubCmds() { | ||
44 | - return tsSubCmds; | ||
45 | - } | ||
46 | - | ||
47 | - public void setTsSubCmds(List<TimeseriesSubscriptionCmd> tsSubCmds) { | ||
48 | - this.tsSubCmds = tsSubCmds; | ||
49 | - } | 39 | + private List<EntityDataCmd> entityDataCmds; |
50 | 40 | ||
51 | - public List<GetHistoryCmd> getHistoryCmds() { | ||
52 | - return historyCmds; | ||
53 | - } | 41 | + private List<EntityDataUnsubscribeCmd> entityDataUnsubscribeCmds; |
54 | 42 | ||
55 | - public void setHistoryCmds(List<GetHistoryCmd> historyCmds) { | ||
56 | - this.historyCmds = historyCmds; | ||
57 | - } | ||
58 | } | 43 | } |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v1/AttributesSubscriptionCmd.java
renamed from
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/AttributesSubscriptionCmd.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.service.telemetry.cmd; | 16 | +package org.thingsboard.server.service.telemetry.cmd.v1; |
17 | 17 | ||
18 | import lombok.NoArgsConstructor; | 18 | import lombok.NoArgsConstructor; |
19 | import org.thingsboard.server.service.telemetry.TelemetryFeature; | 19 | import org.thingsboard.server.service.telemetry.TelemetryFeature; |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v1/GetHistoryCmd.java
renamed from
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/GetHistoryCmd.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.service.telemetry.cmd; | 16 | +package org.thingsboard.server.service.telemetry.cmd.v1; |
17 | 17 | ||
18 | import lombok.AllArgsConstructor; | 18 | import lombok.AllArgsConstructor; |
19 | import lombok.Data; | 19 | import lombok.Data; |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v1/SubscriptionCmd.java
renamed from
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/SubscriptionCmd.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.service.telemetry.cmd; | 16 | +package org.thingsboard.server.service.telemetry.cmd.v1; |
17 | 17 | ||
18 | import lombok.AllArgsConstructor; | 18 | import lombok.AllArgsConstructor; |
19 | import lombok.Data; | 19 | import lombok.Data; |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v1/TelemetryPluginCmd.java
renamed from
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/TelemetryPluginCmd.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.service.telemetry.cmd; | 16 | +package org.thingsboard.server.service.telemetry.cmd.v1; |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * @author Andrew Shvayka | 19 | * @author Andrew Shvayka |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v1/TimeseriesSubscriptionCmd.java
renamed from
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/TimeseriesSubscriptionCmd.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.service.telemetry.cmd; | 16 | +package org.thingsboard.server.service.telemetry.cmd.v1; |
17 | 17 | ||
18 | import lombok.AllArgsConstructor; | 18 | import lombok.AllArgsConstructor; |
19 | import lombok.Data; | 19 | import lombok.Data; |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v2/EntityDataCmd.java
0 → 100644
1 | +package org.thingsboard.server.service.telemetry.cmd.v2; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import org.thingsboard.server.common.data.query.EntityDataQuery; | ||
5 | + | ||
6 | +@Data | ||
7 | +public class EntityDataCmd { | ||
8 | + | ||
9 | + private final int cmdId; | ||
10 | + private final EntityDataQuery query; | ||
11 | + private final EntityHistoryCmd historyCmd; | ||
12 | + private final LatestValueCmd latestCmd; | ||
13 | + private final TimeSeriesCmd tsCmd; | ||
14 | + | ||
15 | +} |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v2/EntityDataUpdate.java
0 → 100644
1 | +package org.thingsboard.server.service.telemetry.cmd.v2; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import org.thingsboard.server.common.data.page.PageData; | ||
5 | +import org.thingsboard.server.common.data.query.EntityData; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +@Data | ||
10 | +public class EntityDataUpdate { | ||
11 | + | ||
12 | + private final int cmdId; | ||
13 | + private final PageData<EntityData> data; | ||
14 | + private final List<EntityData> update; | ||
15 | + private int errorCode; | ||
16 | + private String errorMsg; | ||
17 | +} |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v2/EntityHistoryCmd.java
0 → 100644
1 | +package org.thingsboard.server.service.telemetry.cmd.v2; | ||
2 | + | ||
3 | +import org.thingsboard.server.common.data.kv.Aggregation; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public class EntityHistoryCmd { | ||
8 | + | ||
9 | + private List<String> keys; | ||
10 | + private long startTs; | ||
11 | + private long endTs; | ||
12 | + private long interval; | ||
13 | + private int limit; | ||
14 | + private Aggregation agg; | ||
15 | + | ||
16 | +} |
application/src/main/java/org/thingsboard/server/service/telemetry/cmd/v2/TimeSeriesCmd.java
0 → 100644
1 | +package org.thingsboard.server.service.telemetry.cmd.v2; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +public class TimeSeriesCmd { | ||
6 | + | ||
7 | + private List<String> keys; | ||
8 | + private long startTs; | ||
9 | + private long timeWindow; | ||
10 | + private long interval; | ||
11 | + private int limit; | ||
12 | + private String agg; | ||
13 | + | ||
14 | +} |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | * you may not use this file except in compliance with the License. | 5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at | 6 | * You may obtain a copy of the License at |
7 | * | 7 | * |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * | 9 | * |
10 | * Unless required by applicable law or agreed to in writing, software | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
@@ -18,6 +18,10 @@ package org.thingsboard.server.dao.entity; | @@ -18,6 +18,10 @@ package org.thingsboard.server.dao.entity; | ||
18 | import com.google.common.util.concurrent.ListenableFuture; | 18 | import com.google.common.util.concurrent.ListenableFuture; |
19 | import org.thingsboard.server.common.data.id.EntityId; | 19 | import org.thingsboard.server.common.data.id.EntityId; |
20 | import org.thingsboard.server.common.data.id.TenantId; | 20 | import org.thingsboard.server.common.data.id.TenantId; |
21 | +import org.thingsboard.server.common.data.page.PageData; | ||
22 | +import org.thingsboard.server.common.data.query.EntityCountQuery; | ||
23 | +import org.thingsboard.server.common.data.query.EntityData; | ||
24 | +import org.thingsboard.server.common.data.query.EntityDataQuery; | ||
21 | 25 | ||
22 | public interface EntityService { | 26 | public interface EntityService { |
23 | 27 | ||
@@ -25,4 +29,8 @@ public interface EntityService { | @@ -25,4 +29,8 @@ public interface EntityService { | ||
25 | 29 | ||
26 | void deleteEntityRelations(TenantId tenantId, EntityId entityId); | 30 | void deleteEntityRelations(TenantId tenantId, EntityId entityId); |
27 | 31 | ||
32 | + long countEntitiesByQuery(TenantId tenantId, EntityCountQuery query); | ||
33 | + | ||
34 | + PageData<EntityData> findEntityDataByQuery(TenantId tenantId, EntityDataQuery query); | ||
35 | + | ||
28 | } | 36 | } |
1 | +package org.thingsboard.server.common.data.query; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import org.thingsboard.server.common.data.id.EntityId; | ||
5 | + | ||
6 | +import java.util.Map; | ||
7 | + | ||
8 | +@Data | ||
9 | +public class EntityData { | ||
10 | + | ||
11 | + private final EntityId entityId; | ||
12 | + private final Map<EntityKeyType, Map<String, TsValue>> latest; | ||
13 | + private final Map<String, TsValue[]> timeseries; | ||
14 | + | ||
15 | +} |
common/data/src/main/java/org/thingsboard/server/common/data/query/EntityDataPageLink.java
0 → 100644
1 | +package org.thingsboard.server.common.data.query; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import org.thingsboard.server.common.data.page.SortOrder; | ||
5 | + | ||
6 | +@Data | ||
7 | +public class EntityDataPageLink { | ||
8 | + | ||
9 | + private final int pageSize; | ||
10 | + private final int page; | ||
11 | + private final SortOrder sortOrder; | ||
12 | + | ||
13 | +} |
1 | +package org.thingsboard.server.common.data.query; | ||
2 | + | ||
3 | +import lombok.Getter; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public class EntityDataQuery extends EntityCountQuery { | ||
8 | + | ||
9 | + @Getter | ||
10 | + private final EntityDataPageLink pageLink; | ||
11 | + @Getter | ||
12 | + private final List<EntityKey> entityFields; | ||
13 | + @Getter | ||
14 | + private final List<EntityKey> latestValues; | ||
15 | + | ||
16 | + public EntityDataQuery(EntityFilter entityFilter, EntityDataPageLink pageLink, List<EntityKey> entityFields, List<EntityKey> latestValues) { | ||
17 | + super(entityFilter); | ||
18 | + this.pageLink = pageLink; | ||
19 | + this.entityFields = entityFields; | ||
20 | + this.latestValues = latestValues; | ||
21 | + } | ||
22 | +} |
1 | +package org.thingsboard.server.common.data.query; | ||
2 | + | ||
3 | +public enum EntityFilterType { | ||
4 | + SINGLE_ENTITY("singleEntity"), | ||
5 | + ENTITY_LIST("entityList"), | ||
6 | + ENTITY_NAME("entityName"); | ||
7 | +// stateEntity = 'stateEntity', | ||
8 | +// assetType = 'assetType', | ||
9 | +// deviceType = 'deviceType', | ||
10 | +// entityViewType = 'entityViewType', | ||
11 | +// relationsQuery = 'relationsQuery', | ||
12 | +// assetSearchQuery = 'assetSearchQuery', | ||
13 | +// deviceSearchQuery = 'deviceSearchQuery', | ||
14 | +// entityViewSearchQuery = 'entityViewSearchQuery' | ||
15 | + | ||
16 | + private final String label; | ||
17 | + | ||
18 | + EntityFilterType(String label) { | ||
19 | + this.label = label; | ||
20 | + } | ||
21 | +} |
common/data/src/main/java/org/thingsboard/server/common/data/query/SingleEntityFilter.java
0 → 100644
1 | +package org.thingsboard.server.common.data.query; | ||
2 | + | ||
3 | +import lombok.Data; | ||
4 | +import org.thingsboard.server.common.data.id.EntityId; | ||
5 | + | ||
6 | +@Data | ||
7 | +public class SingleEntityFilter implements EntityFilter { | ||
8 | + @Override | ||
9 | + public EntityFilterType getType() { | ||
10 | + return EntityFilterType.SINGLE_ENTITY; | ||
11 | + } | ||
12 | + | ||
13 | + private EntityId singleEntity; | ||
14 | + | ||
15 | +} |
@@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.id.EntityViewId; | @@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.id.EntityViewId; | ||
33 | import org.thingsboard.server.common.data.id.RuleChainId; | 33 | import org.thingsboard.server.common.data.id.RuleChainId; |
34 | import org.thingsboard.server.common.data.id.TenantId; | 34 | import org.thingsboard.server.common.data.id.TenantId; |
35 | import org.thingsboard.server.common.data.id.UserId; | 35 | import org.thingsboard.server.common.data.id.UserId; |
36 | +import org.thingsboard.server.common.data.query.EntityDataQuery; | ||
36 | import org.thingsboard.server.dao.alarm.AlarmService; | 37 | import org.thingsboard.server.dao.alarm.AlarmService; |
37 | import org.thingsboard.server.dao.asset.AssetService; | 38 | import org.thingsboard.server.dao.asset.AssetService; |
38 | import org.thingsboard.server.dao.customer.CustomerService; | 39 | import org.thingsboard.server.dao.customer.CustomerService; |
@@ -83,6 +84,11 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe | @@ -83,6 +84,11 @@ public class BaseEntityService extends AbstractEntityService implements EntitySe | ||
83 | } | 84 | } |
84 | 85 | ||
85 | @Override | 86 | @Override |
87 | + public long countEntitiesByQuery(TenantId tenantId, EntityDataQuery query) { | ||
88 | + return 0; | ||
89 | + } | ||
90 | + | ||
91 | + @Override | ||
86 | public ListenableFuture<String> fetchEntityNameAsync(TenantId tenantId, EntityId entityId) { | 92 | public ListenableFuture<String> fetchEntityNameAsync(TenantId tenantId, EntityId entityId) { |
87 | log.trace("Executing fetchEntityNameAsync [{}]", entityId); | 93 | log.trace("Executing fetchEntityNameAsync [{}]", entityId); |
88 | ListenableFuture<String> entityName; | 94 | ListenableFuture<String> entityName; |