...
|
...
|
@@ -54,6 +54,8 @@ import org.thingsboard.server.common.data.relation.EntityRelationsQuery; |
54
|
54
|
import org.thingsboard.server.common.data.relation.EntitySearchDirection;
|
55
|
55
|
import org.thingsboard.server.common.data.relation.RelationsSearchParameters;
|
56
|
56
|
import org.thingsboard.server.common.data.rule.RuleChain;
|
|
57
|
+import org.thingsboard.server.common.data.widget.WidgetType;
|
|
58
|
+import org.thingsboard.server.common.data.widget.WidgetsBundle;
|
57
|
59
|
import org.thingsboard.server.dao.asset.AssetService;
|
58
|
60
|
import org.thingsboard.server.dao.attributes.AttributesService;
|
59
|
61
|
import org.thingsboard.server.dao.dashboard.DashboardService;
|
...
|
...
|
@@ -63,6 +65,8 @@ import org.thingsboard.server.dao.entityview.EntityViewService; |
63
|
65
|
import org.thingsboard.server.dao.relation.RelationService;
|
64
|
66
|
import org.thingsboard.server.dao.rule.RuleChainService;
|
65
|
67
|
import org.thingsboard.server.dao.user.UserService;
|
|
68
|
+import org.thingsboard.server.dao.widget.WidgetTypeService;
|
|
69
|
+import org.thingsboard.server.dao.widget.WidgetsBundleService;
|
66
|
70
|
import org.thingsboard.server.gen.edge.AttributesRequestMsg;
|
67
|
71
|
import org.thingsboard.server.gen.edge.DeviceCredentialsRequestMsg;
|
68
|
72
|
import org.thingsboard.server.gen.edge.RelationRequestMsg;
|
...
|
...
|
@@ -110,6 +114,12 @@ public class DefaultSyncEdgeService implements SyncEdgeService { |
110
|
114
|
private UserService userService;
|
111
|
115
|
|
112
|
116
|
@Autowired
|
|
117
|
+ private WidgetsBundleService widgetsBundleService;
|
|
118
|
+
|
|
119
|
+ @Autowired
|
|
120
|
+ private WidgetTypeService widgetTypeService;
|
|
121
|
+
|
|
122
|
+ @Autowired
|
113
|
123
|
private DbCallbackExecutorService dbCallbackExecutorService;
|
114
|
124
|
|
115
|
125
|
@Override
|
...
|
...
|
@@ -121,6 +131,7 @@ public class DefaultSyncEdgeService implements SyncEdgeService { |
121
|
131
|
syncAssets(edge);
|
122
|
132
|
syncEntityViews(edge);
|
123
|
133
|
syncDashboards(edge);
|
|
134
|
+ syncWidgetsBundleAndWidgetTypes(edge);
|
124
|
135
|
} catch (Exception e) {
|
125
|
136
|
log.error("Exception during sync process", e);
|
126
|
137
|
}
|
...
|
...
|
@@ -261,6 +272,24 @@ public class DefaultSyncEdgeService implements SyncEdgeService { |
261
|
272
|
}
|
262
|
273
|
}
|
263
|
274
|
|
|
275
|
+ private void syncWidgetsBundleAndWidgetTypes(Edge edge) {
|
|
276
|
+ List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>();
|
|
277
|
+ List<WidgetType> widgetTypesToPush = new ArrayList<>();
|
|
278
|
+ widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(edge.getTenantId()));
|
|
279
|
+ widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(edge.getTenantId()));
|
|
280
|
+ try {
|
|
281
|
+ for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) {
|
|
282
|
+ saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGETS_BUNDLE, ActionType.ADDED, widgetsBundle.getId(), null);
|
|
283
|
+ widgetTypesToPush.addAll(widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias()));
|
|
284
|
+ }
|
|
285
|
+ for (WidgetType widgetType: widgetTypesToPush) {
|
|
286
|
+ saveEdgeEvent(edge.getTenantId(), edge.getId(), EdgeEventType.WIDGET_TYPE, ActionType.ADDED, widgetType.getId(), null);
|
|
287
|
+ }
|
|
288
|
+ } catch (Exception e) {
|
|
289
|
+ log.error("Exception during loading widgets bundle(s) and widget type(s) on sync!", e);
|
|
290
|
+ }
|
|
291
|
+ }
|
|
292
|
+
|
264
|
293
|
private void pushUsersToEdge(TextPageData<User> pageData, Edge edge) {
|
265
|
294
|
if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
|
266
|
295
|
log.trace("[{}] [{}] user(s) are going to be pushed to edge.", edge.getId(), pageData.getData().size());
|
...
|
...
|
|