Showing
1 changed file
with
191 additions
and
192 deletions
... | ... | @@ -47,221 +47,220 @@ import static org.thingsboard.server.common.data.yunteng.constant.QueryConstant. |
47 | 47 | @RequestMapping("api/yt/convert") |
48 | 48 | @Api(tags = {"数据流转控制器"}) |
49 | 49 | public class YtConvertDataToController extends BaseController { |
50 | - private final YtRuleChainService ytRuleChainService; | |
50 | + private final YtRuleChainService ytRuleChainService; | |
51 | 51 | |
52 | - @Value("${actors.rule.chain.debug_mode_rate_limits_per_tenant.enabled}") | |
53 | - private boolean debugPerTenantEnabled; | |
52 | + @Value("${actors.rule.chain.debug_mode_rate_limits_per_tenant.enabled}") | |
53 | + private boolean debugPerTenantEnabled; | |
54 | 54 | |
55 | - @Autowired(required = false) | |
56 | - private ActorSystemContext actorContext; | |
55 | + @Autowired(required = false) | |
56 | + private ActorSystemContext actorContext; | |
57 | 57 | |
58 | - private final ConvertConfigService convertConfigService; | |
59 | - private final SceneLinkageService sceneLinkageService; | |
58 | + private final ConvertConfigService convertConfigService; | |
59 | + private final SceneLinkageService sceneLinkageService; | |
60 | 60 | |
61 | - @GetMapping(params = {PAGE_SIZE, PAGE}) | |
62 | - @ApiOperation("分页查询") | |
63 | - public YtPageData<ConvertConfigDTO> pageMessageConfig( | |
64 | - @RequestParam(PAGE_SIZE) int pageSize, | |
65 | - @RequestParam(PAGE) int page, | |
66 | - @ApiParam(value = "0:转换脚本 1:数据流转") @RequestParam(value = "nodeType") Integer nodeType, | |
67 | - @RequestParam(value = "name", required = false) String name, | |
68 | - @RequestParam(value = "status", required = false) Integer status, | |
69 | - @RequestParam(value = ORDER_FILED, required = false) String orderBy, | |
70 | - @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | |
71 | - throws ThingsboardException { | |
61 | + @GetMapping(params = {PAGE_SIZE, PAGE}) | |
62 | + @ApiOperation("分页查询") | |
63 | + public YtPageData<ConvertConfigDTO> pageMessageConfig( | |
64 | + @RequestParam(PAGE_SIZE) int pageSize, | |
65 | + @RequestParam(PAGE) int page, | |
66 | + @ApiParam(value = "0:转换脚本 1:数据流转") @RequestParam(value = "nodeType") Integer nodeType, | |
67 | + @RequestParam(value = "name", required = false) String name, | |
68 | + @RequestParam(value = "status", required = false) Integer status, | |
69 | + @RequestParam(value = ORDER_FILED, required = false) String orderBy, | |
70 | + @RequestParam(value = ORDER_TYPE, required = false) OrderTypeEnum orderType) | |
71 | + throws ThingsboardException { | |
72 | 72 | |
73 | - HashMap<String, Object> queryMap = new HashMap<>(); | |
74 | - queryMap.put(PAGE_SIZE, pageSize); | |
75 | - queryMap.put(PAGE, page); | |
76 | - queryMap.put(ORDER_FILED, orderBy); | |
77 | - queryMap.put("nodeType", nodeType); | |
78 | - queryMap.put("name", name); | |
79 | - queryMap.put("status", status); | |
80 | - if (orderType != null) { | |
81 | - queryMap.put(ORDER_TYPE, orderType.name()); | |
73 | + HashMap<String, Object> queryMap = new HashMap<>(); | |
74 | + queryMap.put(PAGE_SIZE, pageSize); | |
75 | + queryMap.put(PAGE, page); | |
76 | + queryMap.put(ORDER_FILED, orderBy); | |
77 | + queryMap.put("nodeType", nodeType); | |
78 | + queryMap.put("name", name); | |
79 | + queryMap.put("status", status); | |
80 | + if (orderType != null) { | |
81 | + queryMap.put(ORDER_TYPE, orderType.name()); | |
82 | + } | |
83 | + return convertConfigService.page(getCurrentUser().getCurrentTenantId(), queryMap); | |
82 | 84 | } |
83 | - return convertConfigService.page(getCurrentUser().getCurrentTenantId(), queryMap); | |
84 | - } | |
85 | - | |
86 | - @PostMapping("config") | |
87 | - @ApiOperation("添加或修改转换配置") | |
88 | - public ResponseEntity<ConvertConfigDTO> createOrUpdateConvertData( | |
89 | - @Validated @RequestBody ConvertConfigDTO convertConfigDTO) throws ThingsboardException { | |
90 | - convertConfigDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
91 | - convertConfigDTO.setNodeType(FastIotConstants.CONVERT_DATA); | |
92 | - return ResponseEntity.ok(convertConfigService.createOrUpdate(convertConfigDTO)); | |
93 | - } | |
94 | 85 | |
95 | - @PostMapping("js") | |
96 | - @ApiOperation("添加或修改转换脚本") | |
97 | - public ResponseEntity<ConvertConfigDTO> createOrUpdateConvertJS( | |
98 | - @Validated @RequestBody ConvertConfigDTO convertConfigDTO) throws ThingsboardException { | |
99 | - convertConfigDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
100 | - convertConfigDTO.setNodeType(FastIotConstants.JAVA_SCRIPT); | |
101 | - return ResponseEntity.ok(convertConfigService.createOrUpdate(convertConfigDTO)); | |
102 | - } | |
103 | - | |
104 | - @PostMapping("/check/config") | |
105 | - @ApiOperation("检查配置名称是否存在") | |
106 | - public ResponseEntity<Boolean> checkConvertConfig(@RequestBody Map<String, String> checkParam) | |
107 | - throws ThingsboardException { | |
108 | - String type = checkParam.get("type"); | |
109 | - String name = checkParam.get("name"); | |
110 | - if (StringUtils.isEmpty(type) || StringUtils.isEmpty(name)) { | |
111 | - throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | |
86 | + @PostMapping("config") | |
87 | + @ApiOperation("添加或修改转换配置") | |
88 | + public ResponseEntity<ConvertConfigDTO> createOrUpdateConvertData( | |
89 | + @Validated @RequestBody ConvertConfigDTO convertConfigDTO) throws ThingsboardException { | |
90 | + convertConfigDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
91 | + convertConfigDTO.setNodeType(FastIotConstants.CONVERT_DATA); | |
92 | + return ResponseEntity.ok(convertConfigService.createOrUpdate(convertConfigDTO)); | |
112 | 93 | } |
113 | - return ResponseEntity.ok( | |
114 | - convertConfigService.checkConvertConfigNameExist( | |
115 | - null, name, type, getCurrentUser().getCurrentTenantId())); | |
116 | - } | |
117 | 94 | |
118 | - @DeleteMapping("config") | |
119 | - @ApiOperation("删除转换配置") | |
120 | - public ResponseEntity<Boolean> deleteConfig( | |
121 | - @Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | |
122 | - return delete(deleteDTO, FastIotConstants.CONVERT_DATA); | |
123 | - } | |
95 | + @PostMapping("js") | |
96 | + @ApiOperation("添加或修改转换脚本") | |
97 | + public ResponseEntity<ConvertConfigDTO> createOrUpdateConvertJS( | |
98 | + @Validated @RequestBody ConvertConfigDTO convertConfigDTO) throws ThingsboardException { | |
99 | + convertConfigDTO.setTenantId(getCurrentUser().getCurrentTenantId()); | |
100 | + convertConfigDTO.setNodeType(FastIotConstants.JAVA_SCRIPT); | |
101 | + return ResponseEntity.ok(convertConfigService.createOrUpdate(convertConfigDTO)); | |
102 | + } | |
124 | 103 | |
125 | - @DeleteMapping("js") | |
126 | - @ApiOperation("删除转换脚本") | |
127 | - public ResponseEntity<Boolean> deleteJS( | |
128 | - @Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | |
129 | - return delete(deleteDTO, FastIotConstants.JAVA_SCRIPT); | |
130 | - } | |
104 | + @PostMapping("/check/config") | |
105 | + @ApiOperation("检查配置名称是否存在") | |
106 | + public ResponseEntity<Boolean> checkConvertConfig(@RequestBody Map<String, String> checkParam) | |
107 | + throws ThingsboardException { | |
108 | + String type = checkParam.get("type"); | |
109 | + String name = checkParam.get("name"); | |
110 | + if (StringUtils.isEmpty(type) || StringUtils.isEmpty(name)) { | |
111 | + throw new YtDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); | |
112 | + } | |
113 | + return ResponseEntity.ok( | |
114 | + convertConfigService.checkConvertConfigNameExist( | |
115 | + null, name, type, getCurrentUser().getCurrentTenantId())); | |
116 | + } | |
131 | 117 | |
132 | - @PostMapping("update/config") | |
133 | - @ApiOperation("启用或禁用配置") | |
134 | - public RuleChainMetaData updateConfig( | |
135 | - @Validated(UpdateGroup.class) @RequestBody ConvertConfigReqDTO convertConfigReqDTO) | |
136 | - throws ThingsboardException { | |
137 | - if (convertConfigService.checkConvertConfigStatusExist( | |
138 | - convertConfigReqDTO.getConvertIds(), | |
139 | - convertConfigReqDTO.getStatus(), | |
140 | - getCurrentUser().getCurrentTenantId())) { | |
141 | - throw new YtDataValidationException(ErrorMessage.DATA_ALREADY_EXISTS.getMessage()); | |
118 | + @DeleteMapping("config") | |
119 | + @ApiOperation("删除转换配置") | |
120 | + public ResponseEntity<Boolean> deleteConfig( | |
121 | + @Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | |
122 | + return delete(deleteDTO, FastIotConstants.CONVERT_DATA); | |
142 | 123 | } |
143 | - List<String> ids = convertConfigReqDTO.getConvertIds(); | |
144 | - int status = convertConfigReqDTO.getStatus(); | |
145 | - List<RuleNode> nodes = | |
146 | - convertConfigService.getRuleNodesByConvertConfigIds( | |
147 | - ids, null, FastIotConstants.CONVERT_DATA); | |
148 | - RuleChainMetaData ruleChainMetaData = new RuleChainMetaData(); | |
149 | - if (null != nodes && nodes.size() > 0) { | |
150 | - ruleChainMetaData = saveRuleChain(nodes, status, FastIotConstants.CONVERT_DATA); | |
124 | + | |
125 | + @DeleteMapping("js") | |
126 | + @ApiOperation("删除转换脚本") | |
127 | + public ResponseEntity<Boolean> deleteJS( | |
128 | + @Validated(DeleteGroup.class) @RequestBody DeleteDTO deleteDTO) throws ThingsboardException { | |
129 | + return delete(deleteDTO, FastIotConstants.JAVA_SCRIPT); | |
151 | 130 | } |
152 | - convertConfigService.updateConvertStatusByIds( | |
153 | - ids, status, getCurrentUser().getCurrentTenantId()); | |
154 | - return ruleChainMetaData; | |
155 | - } | |
156 | 131 | |
157 | - @PostMapping("update/js") | |
158 | - @ApiOperation("启用或禁用转换脚本") | |
159 | - public RuleChainMetaData updateJs( | |
160 | - @Validated(UpdateGroup.class) @RequestBody ConvertReqDTO convertJSReqDTO) | |
161 | - throws ThingsboardException { | |
162 | - int status = convertJSReqDTO.getStatus(); | |
163 | - if (status == FastIotConstants.StateValue.ENABLE | |
164 | - && convertConfigService.checkConvertJSStatusEnable(getCurrentUser().getCurrentTenantId())) { | |
165 | - throw new YtDataValidationException(ErrorMessage.CONVERT_JS_IS_ALONE.getMessage()); | |
132 | + @PostMapping("update/config") | |
133 | + @ApiOperation("启用或禁用配置") | |
134 | + public RuleChainMetaData updateConfig( | |
135 | + @Validated(UpdateGroup.class) @RequestBody ConvertConfigReqDTO convertConfigReqDTO) | |
136 | + throws ThingsboardException { | |
137 | + if (convertConfigService.checkConvertConfigStatusExist( | |
138 | + convertConfigReqDTO.getConvertIds(), | |
139 | + convertConfigReqDTO.getStatus(), | |
140 | + getCurrentUser().getCurrentTenantId())) { | |
141 | + throw new YtDataValidationException(ErrorMessage.DATA_ALREADY_EXISTS.getMessage()); | |
142 | + } | |
143 | + List<String> ids = convertConfigReqDTO.getConvertIds(); | |
144 | + int status = convertConfigReqDTO.getStatus(); | |
145 | + List<RuleNode> nodes = | |
146 | + convertConfigService.getRuleNodesByConvertConfigIds( | |
147 | + ids, null, FastIotConstants.CONVERT_DATA); | |
148 | + RuleChainMetaData ruleChainMetaData = new RuleChainMetaData(); | |
149 | + if (null != nodes && nodes.size() > 0) { | |
150 | + ruleChainMetaData = saveRuleChain(nodes, status, FastIotConstants.CONVERT_DATA); | |
151 | + } | |
152 | + convertConfigService.updateConvertStatusByIds( | |
153 | + ids, status, getCurrentUser().getCurrentTenantId()); | |
154 | + return ruleChainMetaData; | |
166 | 155 | } |
167 | - List<String> ids = new ArrayList<>(); | |
168 | - ids.add(convertJSReqDTO.getId()); | |
169 | - List<RuleNode> nodes = | |
170 | - convertConfigService.getRuleNodesByConvertConfigIds( | |
171 | - ids, null, FastIotConstants.JAVA_SCRIPT); | |
172 | 156 | |
173 | - RuleChainMetaData ruleChainMetaData = | |
174 | - saveRuleChain(nodes, status, FastIotConstants.JAVA_SCRIPT); | |
175 | - convertConfigService.updateConvertStatusByIds( | |
176 | - ids, status, getCurrentUser().getCurrentTenantId()); | |
177 | - return ruleChainMetaData; | |
178 | - } | |
157 | + @PostMapping("update/js") | |
158 | + @ApiOperation("启用或禁用转换脚本") | |
159 | + public RuleChainMetaData updateJs( | |
160 | + @Validated(UpdateGroup.class) @RequestBody ConvertReqDTO convertJSReqDTO) | |
161 | + throws ThingsboardException { | |
162 | + int status = convertJSReqDTO.getStatus(); | |
163 | + if (status == FastIotConstants.StateValue.ENABLE | |
164 | + && convertConfigService.checkConvertJSStatusEnable(getCurrentUser().getCurrentTenantId())) { | |
165 | + throw new YtDataValidationException(ErrorMessage.CONVERT_JS_IS_ALONE.getMessage()); | |
166 | + } | |
167 | + List<String> ids = new ArrayList<>(); | |
168 | + ids.add(convertJSReqDTO.getId()); | |
169 | + List<RuleNode> nodes = | |
170 | + convertConfigService.getRuleNodesByConvertConfigIds( | |
171 | + ids, null, FastIotConstants.JAVA_SCRIPT); | |
179 | 172 | |
180 | - @PostMapping("update/scene") | |
181 | - @ApiOperation("启用或禁用场景联动") | |
182 | - public RuleChainMetaData updateScene( | |
183 | - @Validated(UpdateGroup.class) @RequestBody ConvertReqDTO convertReqDTO) | |
184 | - throws ThingsboardException { | |
185 | - //TODO 通过接口获取JsonNode | |
186 | - int status = -1; | |
187 | - String sceneId = convertReqDTO.getId(); | |
188 | - String currentTenant = getCurrentUser().getCurrentTenantId(); | |
189 | - Integer sceneStatus = convertReqDTO.getStatus(); | |
190 | - JsonNode configuration = sceneLinkageService.getRuleNodeConfig(sceneId,currentTenant,getCurrentUser().getCustomerId().getId().toString(),sceneStatus); | |
191 | - boolean noValue = configuration == null; | |
192 | - if (noValue && convertReqDTO.getStatus() == FastIotConstants.StateValue.DISABLE) { | |
193 | - status = FastIotConstants.StateValue.DISABLE; | |
173 | + RuleChainMetaData ruleChainMetaData = | |
174 | + saveRuleChain(nodes, status, FastIotConstants.JAVA_SCRIPT); | |
175 | + convertConfigService.updateConvertStatusByIds( | |
176 | + ids, status, getCurrentUser().getCurrentTenantId()); | |
177 | + return ruleChainMetaData; | |
194 | 178 | } |
195 | - if (!noValue) { | |
196 | - status = FastIotConstants.StateValue.ENABLE; | |
197 | - } | |
198 | - List<RuleNode> ruleNodes = new ArrayList<>(); | |
199 | - RuleNode scene = new RuleNode(); | |
200 | - scene.setName("Scene"); | |
201 | - scene.setType("org.thingsboard.rule.engine.yunteng.scene.TbSceneReactNode"); | |
202 | - scene.setConfiguration(configuration); | |
203 | - ruleNodes.add(scene); | |
204 | - RuleChainMetaData result = saveRuleChain(ruleNodes, status, FastIotConstants.SCENE_REACT); | |
205 | - sceneLinkageService.updateSceneStatus(sceneId,sceneStatus,currentTenant); | |
206 | - return result; | |
207 | - } | |
208 | 179 | |
209 | - /** | |
210 | - * 保存规则链 | |
211 | - * | |
212 | - * @param nodes 规则节点 | |
213 | - * @param status 0禁用 1启用 | |
214 | - * @return 规则节点数据 | |
215 | - */ | |
216 | - private RuleChainMetaData saveRuleChain(List<RuleNode> nodes, Integer status, Integer nodeType) | |
217 | - throws ThingsboardException { | |
218 | - boolean needSaveRuleNode; | |
219 | - TenantId tenantId = getTenantId(); | |
220 | - // 1. GET DEFAULT RULE CHAIN | |
221 | - RuleChain ruleChain = ytRuleChainService.getRootTenantRuleChain(getTenantId()); | |
222 | - // 2. GET RULE CHAIN METADATA | |
223 | - RuleChainMetaData ruleChainMetaData = | |
224 | - ruleChainService.loadRuleChainMetaData(getTenantId(), ruleChain.getId()); | |
225 | - // 3. SETUP CONNECTION AND ADD OR DELETE RULE NODE | |
226 | - if (status == FastIotConstants.MagicNumber.ZERO) { | |
227 | - needSaveRuleNode = convertConfigService.deleteRuleNode(nodes, ruleChainMetaData, nodeType); | |
228 | - } else { | |
229 | - convertConfigService.addRuleNode(nodes, ruleChainMetaData, nodeType); | |
230 | - needSaveRuleNode = true; | |
180 | + @PostMapping("update/scene") | |
181 | + @ApiOperation("启用或禁用场景联动") | |
182 | + public RuleChainMetaData updateScene( | |
183 | + @Validated(UpdateGroup.class) @RequestBody ConvertReqDTO convertReqDTO) | |
184 | + throws ThingsboardException { | |
185 | + int status = -1; | |
186 | + String sceneId = convertReqDTO.getId(); | |
187 | + String currentTenant = getCurrentUser().getCurrentTenantId(); | |
188 | + Integer sceneStatus = convertReqDTO.getStatus(); | |
189 | + JsonNode configuration = sceneLinkageService.getRuleNodeConfig(sceneId, currentTenant, getCurrentUser().getCustomerId().getId().toString(), sceneStatus); | |
190 | + boolean noValue = configuration == null; | |
191 | + if (noValue && convertReqDTO.getStatus() == FastIotConstants.StateValue.DISABLE) { | |
192 | + status = FastIotConstants.StateValue.DISABLE; | |
193 | + } | |
194 | + if (!noValue) { | |
195 | + status = FastIotConstants.StateValue.ENABLE; | |
196 | + } | |
197 | + List<RuleNode> ruleNodes = new ArrayList<>(); | |
198 | + RuleNode scene = new RuleNode(); | |
199 | + scene.setName("Scene"); | |
200 | + scene.setType("org.thingsboard.rule.engine.yunteng.scene.TbSceneReactNode"); | |
201 | + scene.setConfiguration(configuration); | |
202 | + ruleNodes.add(scene); | |
203 | + RuleChainMetaData result = saveRuleChain(ruleNodes, status, FastIotConstants.SCENE_REACT); | |
204 | + sceneLinkageService.updateSceneStatus(sceneId, sceneStatus, currentTenant); | |
205 | + return result; | |
231 | 206 | } |
232 | - // 4. SAVE METADATA | |
233 | - RuleChainMetaData savedRuleChainMetaData = null; | |
234 | - if (needSaveRuleNode) { | |
235 | - if (debugPerTenantEnabled) { | |
236 | - ConcurrentMap<TenantId, DebugTbRateLimits> debugPerTenantLimits = | |
237 | - actorContext.getDebugPerTenantLimits(); | |
238 | - DebugTbRateLimits debugTbRateLimits = debugPerTenantLimits.getOrDefault(tenantId, null); | |
239 | - if (debugTbRateLimits != null) { | |
240 | - debugPerTenantLimits.remove(tenantId, debugTbRateLimits); | |
207 | + | |
208 | + /** | |
209 | + * 保存规则链 | |
210 | + * | |
211 | + * @param nodes 规则节点 | |
212 | + * @param status 0禁用 1启用 | |
213 | + * @return 规则节点数据 | |
214 | + */ | |
215 | + private RuleChainMetaData saveRuleChain(List<RuleNode> nodes, Integer status, Integer nodeType) | |
216 | + throws ThingsboardException { | |
217 | + boolean needSaveRuleNode; | |
218 | + TenantId tenantId = getTenantId(); | |
219 | + // 1. GET DEFAULT RULE CHAIN | |
220 | + RuleChain ruleChain = ytRuleChainService.getRootTenantRuleChain(getTenantId()); | |
221 | + // 2. GET RULE CHAIN METADATA | |
222 | + RuleChainMetaData ruleChainMetaData = | |
223 | + ruleChainService.loadRuleChainMetaData(getTenantId(), ruleChain.getId()); | |
224 | + // 3. SETUP CONNECTION AND ADD OR DELETE RULE NODE | |
225 | + if (status == FastIotConstants.MagicNumber.ZERO) { | |
226 | + needSaveRuleNode = convertConfigService.deleteRuleNode(nodes, ruleChainMetaData, nodeType); | |
227 | + } else { | |
228 | + convertConfigService.addRuleNode(nodes, ruleChainMetaData, nodeType); | |
229 | + needSaveRuleNode = true; | |
241 | 230 | } |
242 | - } | |
243 | - checkNotNull( | |
244 | - ruleChainService.saveRuleChainMetaData(tenantId, ruleChainMetaData) ? true : null); | |
245 | - savedRuleChainMetaData = | |
246 | - checkNotNull( | |
247 | - ruleChainService.loadRuleChainMetaData(tenantId, ruleChainMetaData.getRuleChainId())); | |
231 | + // 4. SAVE METADATA | |
232 | + RuleChainMetaData savedRuleChainMetaData = null; | |
233 | + if (needSaveRuleNode) { | |
234 | + if (debugPerTenantEnabled) { | |
235 | + ConcurrentMap<TenantId, DebugTbRateLimits> debugPerTenantLimits = | |
236 | + actorContext.getDebugPerTenantLimits(); | |
237 | + DebugTbRateLimits debugTbRateLimits = debugPerTenantLimits.getOrDefault(tenantId, null); | |
238 | + if (debugTbRateLimits != null) { | |
239 | + debugPerTenantLimits.remove(tenantId, debugTbRateLimits); | |
240 | + } | |
241 | + } | |
242 | + checkNotNull( | |
243 | + ruleChainService.saveRuleChainMetaData(tenantId, ruleChainMetaData) ? true : null); | |
244 | + savedRuleChainMetaData = | |
245 | + checkNotNull( | |
246 | + ruleChainService.loadRuleChainMetaData(tenantId, ruleChainMetaData.getRuleChainId())); | |
248 | 247 | |
249 | - if (RuleChainType.CORE.equals(ruleChain.getType())) { | |
250 | - tbClusterService.broadcastEntityStateChangeEvent( | |
251 | - ruleChain.getTenantId(), ruleChain.getId(), ComponentLifecycleEvent.UPDATED); | |
252 | - } | |
248 | + if (RuleChainType.CORE.equals(ruleChain.getType())) { | |
249 | + tbClusterService.broadcastEntityStateChangeEvent( | |
250 | + ruleChain.getTenantId(), ruleChain.getId(), ComponentLifecycleEvent.UPDATED); | |
251 | + } | |
252 | + } | |
253 | + return savedRuleChainMetaData; | |
253 | 254 | } |
254 | - return savedRuleChainMetaData; | |
255 | - } | |
256 | 255 | |
257 | - private ResponseEntity<Boolean> delete(DeleteDTO deleteDTO, Integer nodeType) | |
258 | - throws ThingsboardException { | |
259 | - List<RuleNode> nodes = | |
260 | - convertConfigService.getRuleNodesByConvertConfigIds( | |
261 | - new ArrayList<>(deleteDTO.getIds()), FastIotConstants.StateValue.ENABLE, nodeType); | |
262 | - if (nodes != null && nodes.size() > FastIotConstants.MagicNumber.ZERO) { | |
263 | - saveRuleChain(nodes, 0, nodeType); | |
256 | + private ResponseEntity<Boolean> delete(DeleteDTO deleteDTO, Integer nodeType) | |
257 | + throws ThingsboardException { | |
258 | + List<RuleNode> nodes = | |
259 | + convertConfigService.getRuleNodesByConvertConfigIds( | |
260 | + new ArrayList<>(deleteDTO.getIds()), FastIotConstants.StateValue.ENABLE, nodeType); | |
261 | + if (nodes != null && nodes.size() > FastIotConstants.MagicNumber.ZERO) { | |
262 | + saveRuleChain(nodes, 0, nodeType); | |
263 | + } | |
264 | + return ResponseEntity.ok(convertConfigService.deleteConvertConfig(deleteDTO, nodeType)); | |
264 | 265 | } |
265 | - return ResponseEntity.ok(convertConfigService.deleteConvertConfig(deleteDTO, nodeType)); | |
266 | - } | |
267 | 266 | } | ... | ... |