Commit 9bce47cdc833ae55deb5d15a75e9ede78799b045

Authored by Volodymyr Babak
1 parent 1fe7642a

Fixed order of widget bundle and types updload

@@ -151,16 +151,17 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -151,16 +151,17 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
151 public void sync(TenantId tenantId, Edge edge) { 151 public void sync(TenantId tenantId, Edge edge) {
152 log.trace("[{}][{}] Staring edge sync process", tenantId, edge.getId()); 152 log.trace("[{}][{}] Staring edge sync process", tenantId, edge.getId());
153 try { 153 try {
154 - syncWidgetsBundleAndWidgetTypes(tenantId, edge); 154 + syncWidgetsBundles(tenantId, edge);
155 // TODO: voba - implement this functionality 155 // TODO: voba - implement this functionality
156 // syncAdminSettings(edge); 156 // syncAdminSettings(edge);
157 - syncRuleChains(tenantId, edge);  
158 syncDeviceProfiles(tenantId, edge); 157 syncDeviceProfiles(tenantId, edge);
  158 + syncRuleChains(tenantId, edge);
159 syncUsers(tenantId, edge); 159 syncUsers(tenantId, edge);
160 - syncDevices(tenantId, edge);  
161 syncAssets(tenantId, edge); 160 syncAssets(tenantId, edge);
162 syncEntityViews(tenantId, edge); 161 syncEntityViews(tenantId, edge);
163 syncDashboards(tenantId, edge); 162 syncDashboards(tenantId, edge);
  163 + syncWidgetsTypes(tenantId, edge);
  164 + syncDevices(tenantId, edge);
164 } catch (Exception e) { 165 } catch (Exception e) {
165 log.error("[{}][{}] Exception during sync process", tenantId, edge.getId(), e); 166 log.error("[{}][{}] Exception during sync process", tenantId, edge.getId(), e);
166 } 167 }
@@ -340,22 +341,35 @@ public class DefaultSyncEdgeService implements SyncEdgeService { @@ -340,22 +341,35 @@ public class DefaultSyncEdgeService implements SyncEdgeService {
340 } 341 }
341 } 342 }
342 343
343 - private void syncWidgetsBundleAndWidgetTypes(TenantId tenantId, Edge edge) {  
344 - log.trace("[{}] syncWidgetsBundleAndWidgetTypes [{}]", tenantId, edge.getName()); 344 + private void syncWidgetsBundles(TenantId tenantId, Edge edge) {
  345 + log.trace("[{}] syncWidgetsBundles [{}]", tenantId, edge.getName());
345 List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>(); 346 List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>();
346 - List<WidgetType> widgetTypesToPush = new ArrayList<>();  
347 widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(tenantId)); 347 widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(tenantId));
348 widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(tenantId)); 348 widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(tenantId));
349 try { 349 try {
350 for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) { 350 for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) {
351 saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGETS_BUNDLE, EdgeEventActionType.ADDED, widgetsBundle.getId(), null); 351 saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGETS_BUNDLE, EdgeEventActionType.ADDED, widgetsBundle.getId(), null);
352 - widgetTypesToPush.addAll(widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias()));  
353 } 352 }
354 - for (WidgetType widgetType: widgetTypesToPush) {  
355 - saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGET_TYPE, EdgeEventActionType.ADDED, widgetType.getId(), null); 353 + } catch (Exception e) {
  354 + log.error("Exception during loading widgets bundle(s) on sync!", e);
  355 + }
  356 + }
  357 +
  358 + private void syncWidgetsTypes(TenantId tenantId, Edge edge) {
  359 + log.trace("[{}] syncWidgetsTypes [{}]", tenantId, edge.getName());
  360 + List<WidgetsBundle> widgetsBundlesToPush = new ArrayList<>();
  361 + widgetsBundlesToPush.addAll(widgetsBundleService.findAllTenantWidgetsBundlesByTenantId(tenantId));
  362 + widgetsBundlesToPush.addAll(widgetsBundleService.findSystemWidgetsBundles(tenantId));
  363 + try {
  364 + for (WidgetsBundle widgetsBundle: widgetsBundlesToPush) {
  365 + List<WidgetType> widgetTypesToPush =
  366 + widgetTypeService.findWidgetTypesByTenantIdAndBundleAlias(widgetsBundle.getTenantId(), widgetsBundle.getAlias());
  367 + for (WidgetType widgetType: widgetTypesToPush) {
  368 + saveEdgeEvent(tenantId, edge.getId(), EdgeEventType.WIDGET_TYPE, EdgeEventActionType.ADDED, widgetType.getId(), null);
  369 + }
356 } 370 }
357 } catch (Exception e) { 371 } catch (Exception e) {
358 - log.error("Exception during loading widgets bundle(s) and widget type(s) on sync!", e); 372 + log.error("Exception during loading widgets type(s) on sync!", e);
359 } 373 }
360 } 374 }
361 375