diff --git a/src/main/java/neatlogic/module/cmdb/process/stephandler/CIEntitySyncProcessUtilHandler.java b/src/main/java/neatlogic/module/cmdb/process/stephandler/CIEntitySyncProcessUtilHandler.java index 3d978a6a2e592f4b7c6ebd230872e0344a750201..b284e33e3aac7d7cbc31a6eec0b0e61d4b6ac668 100644 --- a/src/main/java/neatlogic/module/cmdb/process/stephandler/CIEntitySyncProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/cmdb/process/stephandler/CIEntitySyncProcessUtilHandler.java @@ -1,31 +1,12 @@ package neatlogic.module.cmdb.process.stephandler; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.notify.crossover.INotifyServiceCrossoverService; -import neatlogic.framework.notify.dto.InvokeNotifyPolicyConfigVo; -import neatlogic.framework.process.operationauth.core.IOperationType; import neatlogic.framework.process.constvalue.ProcessTaskOperationType; import neatlogic.framework.process.constvalue.ProcessTaskStepOperationType; -import neatlogic.framework.process.dto.ProcessStepVo; -import neatlogic.framework.process.dto.ProcessStepWorkerPolicyVo; import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.dto.processconfig.ActionConfigActionVo; -import neatlogic.framework.process.dto.processconfig.ActionConfigVo; +import neatlogic.framework.process.operationauth.core.IOperationType; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; -import neatlogic.framework.process.util.ProcessConfigUtil; -import neatlogic.module.cmdb.process.notifyhandler.CiEntitySyncNotifyHandler; -import neatlogic.module.cmdb.process.notifyhandler.CmdbSyncNotifyHandler; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - @Service //@Deprecated public class CIEntitySyncProcessUtilHandler extends ProcessStepInternalHandlerBase { @@ -46,193 +27,31 @@ public class CIEntitySyncProcessUtilHandler extends ProcessStepInternalHandlerBa return null; } - @Override - public void makeupProcessStep(ProcessStepVo processStepVo, JSONObject stepConfigObj) { - /** 组装通知策略id **/ - JSONObject notifyPolicyConfig = stepConfigObj.getJSONObject("notifyPolicyConfig"); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = JSONObject.toJavaObject(notifyPolicyConfig, InvokeNotifyPolicyConfigVo.class); - if (invokeNotifyPolicyConfigVo != null) { - processStepVo.setNotifyPolicyConfig(invokeNotifyPolicyConfigVo); - } - - JSONObject actionConfig = stepConfigObj.getJSONObject("actionConfig"); - ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); - if (actionConfigVo != null) { - List actionList = actionConfigVo.getActionList(); - if (CollectionUtils.isNotEmpty(actionList)) { - List integrationUuidList = new ArrayList<>(); - for (ActionConfigActionVo actionVo : actionList) { - String integrationUuid = actionVo.getIntegrationUuid(); - if (StringUtils.isNotBlank(integrationUuid)) { - integrationUuidList.add(integrationUuid); - } - } - processStepVo.setIntegrationUuidList(integrationUuidList); - } - } - - /** 组装分配策略 **/ - JSONObject workerPolicyConfig = stepConfigObj.getJSONObject("workerPolicyConfig"); - if (MapUtils.isNotEmpty(workerPolicyConfig)) { - JSONArray policyList = workerPolicyConfig.getJSONArray("policyList"); - if (CollectionUtils.isNotEmpty(policyList)) { - List workerPolicyList = new ArrayList<>(); - for (int k = 0; k < policyList.size(); k++) { - JSONObject policyObj = policyList.getJSONObject(k); - if (!"1".equals(policyObj.getString("isChecked"))) { - continue; - } - ProcessStepWorkerPolicyVo processStepWorkerPolicyVo = new ProcessStepWorkerPolicyVo(); - processStepWorkerPolicyVo.setProcessUuid(processStepVo.getProcessUuid()); - processStepWorkerPolicyVo.setProcessStepUuid(processStepVo.getUuid()); - processStepWorkerPolicyVo.setPolicy(policyObj.getString("type")); - processStepWorkerPolicyVo.setSort(k + 1); - processStepWorkerPolicyVo.setConfig(policyObj.getString("config")); - workerPolicyList.add(processStepWorkerPolicyVo); - } - processStepVo.setWorkerPolicyList(workerPolicyList); - } - } - //保存回复模版ID - Long commentTemplateId = stepConfigObj.getLong("commentTemplateId"); - processStepVo.setCommentTemplateId(commentTemplateId); - - JSONArray tagList = stepConfigObj.getJSONArray("tagList"); - if (CollectionUtils.isNotEmpty(tagList)) { - processStepVo.setTagList(tagList.toJavaList(String.class)); - } - // 保存表单场景 - String formSceneUuid = stepConfigObj.getString("formSceneUuid"); - if (StringUtils.isNotBlank(formSceneUuid)) { - processStepVo.setFormSceneUuid(formSceneUuid); - } - /** - * FIXME 设置CMDB节点设置 - */ - JSONObject ciEntitySyncConfig = stepConfigObj.getJSONObject("ciEntitySyncConfig"); - if (ciEntitySyncConfig != null) { - processStepVo.setConfig(ciEntitySyncConfig.toJSONString()); - } - } - @Override public void updateProcessTaskStepUserAndWorker(Long processTaskId, Long processTaskStepId) { } - @SuppressWarnings("serial") - @Override - public JSONObject makeupConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - /** 授权 **/ - IOperationType[] stepActions = { + public IOperationType[] getStepActions() { + return new IOperationType[]{ ProcessTaskStepOperationType.STEP_VIEW, ProcessTaskStepOperationType.STEP_TRANSFER }; - JSONArray authorityList = configObj.getJSONArray("authorityList"); - JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); - resultObj.put("authorityList", authorityArray); - - /** 按钮映射 **/ - IOperationType[] stepButtons = { - ProcessTaskStepOperationType.STEP_COMPLETE, - ProcessTaskStepOperationType.STEP_BACK, - ProcessTaskOperationType.PROCESSTASK_TRANSFER, - ProcessTaskStepOperationType.STEP_ACCEPT - }; - JSONArray customButtonList = configObj.getJSONArray("customButtonList"); - JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); - resultObj.put("customButtonList", customButtonArray); - - /** 状态映射列表 **/ - JSONArray customStatusList = configObj.getJSONArray("customStatusList"); - JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); - resultObj.put("customStatusList", customStatusArray); - - /** 可替换文本列表 **/ - resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); - return resultObj; } @Override - public JSONObject regulateProcessStepConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - - /** 授权 **/ - IOperationType[] stepActions = { - ProcessTaskStepOperationType.STEP_VIEW, - ProcessTaskStepOperationType.STEP_TRANSFER - }; - JSONArray authorityList = null; - Integer enableAuthority = configObj.getInteger("enableAuthority"); - if (Objects.equals(enableAuthority, 1)) { - authorityList = configObj.getJSONArray("authorityList"); - } else { - enableAuthority = 0; - } - resultObj.put("enableAuthority", enableAuthority); - JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); - resultObj.put("authorityList", authorityArray); - - /** 通知 **/ - JSONObject notifyPolicyConfig = configObj.getJSONObject("notifyPolicyConfig"); - INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, CiEntitySyncNotifyHandler.class); - resultObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); - - /** 动作 **/ - JSONObject actionConfig = configObj.getJSONObject("actionConfig"); - ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); - if (actionConfigVo == null) { - actionConfigVo = new ActionConfigVo(); - } - actionConfigVo.setHandler(CmdbSyncNotifyHandler.class.getName()); - resultObj.put("actionConfig", actionConfigVo); - - JSONArray customButtonList = configObj.getJSONArray("customButtonList"); - /** 按钮映射列表 **/ - IOperationType[] stepButtons = { + public IOperationType[] getStepButtons() { + return new IOperationType[]{ ProcessTaskStepOperationType.STEP_COMPLETE, ProcessTaskStepOperationType.STEP_BACK, ProcessTaskOperationType.PROCESSTASK_TRANSFER, ProcessTaskStepOperationType.STEP_ACCEPT }; + } - JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); - resultObj.put("customButtonList", customButtonArray); - /** 状态映射列表 **/ - JSONArray customStatusList = configObj.getJSONArray("customStatusList"); - JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); - resultObj.put("customStatusList", customStatusArray); - - /** 可替换文本列表 **/ - resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); - - /** 关联表单组件 **/ - JSONArray handlerList = configObj.getJSONArray("handlerList"); - if (handlerList == null) { - handlerList = new JSONArray(); - } - resultObj.put("handlerList", handlerList); - - /** 分配处理人 **/ - JSONObject workerPolicyConfig = configObj.getJSONObject("workerPolicyConfig"); - JSONObject workerPolicyObj = ProcessConfigUtil.regulateWorkerPolicyConfig(workerPolicyConfig); - resultObj.put("workerPolicyConfig", workerPolicyObj); - - JSONObject simpleSettings = ProcessConfigUtil.regulateSimpleSettings(configObj); - resultObj.putAll(simpleSettings); - /** 表单场景 **/ - String formSceneUuid = configObj.getString("formSceneUuid"); - String formSceneName = configObj.getString("formSceneName"); - resultObj.put("formSceneUuid", formSceneUuid == null ? "" : formSceneUuid); - resultObj.put("formSceneName", formSceneName == null ? "" : formSceneName); - return resultObj; + @Override + public String[] getRegulateKeyList() { + return new String[]{"authorityList", "notifyPolicyConfig", "actionConfig", "customButtonList", "customStatusList", "replaceableTextList", "workerPolicyConfig", "formSceneUuid", "formSceneName", "autoStart", "isNeedUploadFile", "isNeedContent", "isRequired", "commentTemplateId", "tagList", "handlerList"}; } + } diff --git a/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java b/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java index 4a1a2208e35e6108a0395d042d2450d7e81c89e7..49a20e7d8a88c88aee9af3c1fb671cda9592c3ac 100644 --- a/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java @@ -19,34 +19,20 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import neatlogic.framework.cmdb.dto.transaction.TransactionVo; import neatlogic.framework.crossover.CrossoverServiceFactory; -import neatlogic.framework.notify.crossover.INotifyServiceCrossoverService; -import neatlogic.framework.notify.dto.InvokeNotifyPolicyConfigVo; -import neatlogic.framework.process.operationauth.core.IOperationType; -import neatlogic.framework.process.constvalue.ProcessTaskOperationType; -import neatlogic.framework.process.constvalue.ProcessTaskStepOperationType; import neatlogic.framework.process.crossover.IProcessTaskStepDataCrossoverMapper; -import neatlogic.framework.process.dto.ProcessStepVo; -import neatlogic.framework.process.dto.ProcessStepWorkerPolicyVo; import neatlogic.framework.process.dto.ProcessTaskStepDataVo; import neatlogic.framework.process.dto.ProcessTaskStepVo; -import neatlogic.framework.process.dto.processconfig.ActionConfigActionVo; -import neatlogic.framework.process.dto.processconfig.ActionConfigVo; import neatlogic.framework.process.stephandler.core.ProcessStepInternalHandlerBase; -import neatlogic.framework.process.util.ProcessConfigUtil; import neatlogic.framework.util.TableResultUtil; -import neatlogic.module.cmdb.process.dto.*; -import neatlogic.module.cmdb.process.exception.CiEntityConfigIllegalException; -import neatlogic.module.cmdb.process.notifyhandler.CmdbSyncNotifyHandler; import neatlogic.module.cmdb.service.transaction.TransactionService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Resource; -import java.util.*; -import java.util.stream.Collectors; +import java.util.ArrayList; +import java.util.List; @Deprecated //@Service public class CmdbSyncProcessUtilHandler extends ProcessStepInternalHandlerBase { @@ -116,514 +102,455 @@ public class CmdbSyncProcessUtilHandler extends ProcessStepInternalHandlerBase { return resultObj; } - @Override - public void makeupProcessStep(ProcessStepVo processStepVo, JSONObject stepConfigObj) { - /* 组装通知策略id **/ - JSONObject notifyPolicyConfig = stepConfigObj.getJSONObject("notifyPolicyConfig"); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = JSONObject.toJavaObject(notifyPolicyConfig, InvokeNotifyPolicyConfigVo.class); - if (invokeNotifyPolicyConfigVo != null) { - processStepVo.setNotifyPolicyConfig(invokeNotifyPolicyConfigVo); - } - - JSONObject actionConfig = stepConfigObj.getJSONObject("actionConfig"); - ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); - if (actionConfigVo != null) { - List actionList = actionConfigVo.getActionList(); - if (CollectionUtils.isNotEmpty(actionList)) { - List integrationUuidList = new ArrayList<>(); - for (ActionConfigActionVo actionVo : actionList) { - String integrationUuid = actionVo.getIntegrationUuid(); - if (StringUtils.isNotBlank(integrationUuid)) { - integrationUuidList.add(integrationUuid); - } - } - processStepVo.setIntegrationUuidList(integrationUuidList); - } - } - - /* 组装分配策略 **/ - JSONObject workerPolicyConfig = stepConfigObj.getJSONObject("workerPolicyConfig"); - if (MapUtils.isNotEmpty(workerPolicyConfig)) { - JSONArray policyList = workerPolicyConfig.getJSONArray("policyList"); - if (CollectionUtils.isNotEmpty(policyList)) { - List workerPolicyList = new ArrayList<>(); - for (int k = 0; k < policyList.size(); k++) { - JSONObject policyObj = policyList.getJSONObject(k); - if (!"1".equals(policyObj.getString("isChecked"))) { - continue; - } - ProcessStepWorkerPolicyVo processStepWorkerPolicyVo = new ProcessStepWorkerPolicyVo(); - processStepWorkerPolicyVo.setProcessUuid(processStepVo.getProcessUuid()); - processStepWorkerPolicyVo.setProcessStepUuid(processStepVo.getUuid()); - processStepWorkerPolicyVo.setPolicy(policyObj.getString("type")); - processStepWorkerPolicyVo.setSort(k + 1); - processStepWorkerPolicyVo.setConfig(policyObj.getString("config")); - workerPolicyList.add(processStepWorkerPolicyVo); - } - processStepVo.setWorkerPolicyList(workerPolicyList); - } - } - - JSONArray tagList = stepConfigObj.getJSONArray("tagList"); - if (CollectionUtils.isNotEmpty(tagList)) { - processStepVo.setTagList(tagList.toJavaList(String.class)); - } - // 保存表单场景 - String formSceneUuid = stepConfigObj.getString("formSceneUuid"); - if (StringUtils.isNotBlank(formSceneUuid)) { - processStepVo.setFormSceneUuid(formSceneUuid); - } - } - @Override public void updateProcessTaskStepUserAndWorker(Long processTaskId, Long processTaskStepId) { } - @SuppressWarnings("serial") - @Override - public JSONObject makeupConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - - /** 授权 **/ - IOperationType[] stepActions = { - ProcessTaskStepOperationType.STEP_VIEW, - ProcessTaskStepOperationType.STEP_TRANSFER - }; - JSONArray authorityList = configObj.getJSONArray("authorityList"); - JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); - resultObj.put("authorityList", authorityArray); - - /* 按钮映射 **/ - IOperationType[] stepButtons = { - ProcessTaskStepOperationType.STEP_COMPLETE, - ProcessTaskStepOperationType.STEP_BACK, - ProcessTaskOperationType.PROCESSTASK_TRANSFER, - ProcessTaskStepOperationType.STEP_ACCEPT - }; - JSONArray customButtonList = configObj.getJSONArray("customButtonList"); - JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); - resultObj.put("customButtonList", customButtonArray); - - /* 状态映射列表 **/ - JSONArray customStatusList = configObj.getJSONArray("customStatusList"); - JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); - resultObj.put("customStatusList", customStatusArray); - - /* 可替换文本列表 **/ - resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); - return resultObj; - } - - @Override - public JSONObject regulateProcessStepConfig(JSONObject configObj) { - if (configObj == null) { - configObj = new JSONObject(); - } - JSONObject resultObj = new JSONObject(); - - /* 授权 **/ - IOperationType[] stepActions = { - ProcessTaskStepOperationType.STEP_VIEW, - ProcessTaskStepOperationType.STEP_TRANSFER - }; - JSONArray authorityList = null; - Integer enableAuthority = configObj.getInteger("enableAuthority"); - if (Objects.equals(enableAuthority, 1)) { - authorityList = configObj.getJSONArray("authorityList"); - } else { - enableAuthority = 0; - } - resultObj.put("enableAuthority", enableAuthority); - JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); - resultObj.put("authorityList", authorityArray); - - /** 通知 **/ - JSONObject notifyPolicyConfig = configObj.getJSONObject("notifyPolicyConfig"); - INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); - InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, CmdbSyncNotifyHandler.class); - resultObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); - - /** 动作 **/ - JSONObject actionConfig = configObj.getJSONObject("actionConfig"); - ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); - if (actionConfigVo == null) { - actionConfigVo = new ActionConfigVo(); - } - actionConfigVo.setHandler(CmdbSyncNotifyHandler.class.getName()); - resultObj.put("actionConfig", actionConfigVo); - - JSONArray customButtonList = configObj.getJSONArray("customButtonList"); - /* 按钮映射列表 **/ - IOperationType[] stepButtons = { - ProcessTaskStepOperationType.STEP_COMPLETE, - ProcessTaskStepOperationType.STEP_BACK, - ProcessTaskOperationType.PROCESSTASK_TRANSFER, - ProcessTaskStepOperationType.STEP_ACCEPT - }; - - JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); - resultObj.put("customButtonList", customButtonArray); - /* 状态映射列表 **/ - JSONArray customStatusList = configObj.getJSONArray("customStatusList"); - JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); - resultObj.put("customStatusList", customStatusArray); - - /* 可替换文本列表 **/ - resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); - - /* 自动化配置 **/ - JSONObject ciEntityConfig = configObj.getJSONObject("ciEntityConfig"); - CiEntitySyncVo ciEntitySyncVo = regulateCiEntityConfig(ciEntityConfig); - resultObj.put("ciEntityConfig", ciEntitySyncVo); - - /* 分配处理人 **/ - JSONObject workerPolicyConfig = configObj.getJSONObject("workerPolicyConfig"); - JSONObject workerPolicyObj = ProcessConfigUtil.regulateWorkerPolicyConfig(workerPolicyConfig); - resultObj.put("workerPolicyConfig", workerPolicyObj); - - JSONObject simpleSettings = ProcessConfigUtil.regulateSimpleSettings(configObj); - resultObj.putAll(simpleSettings); - /* 表单场景 **/ - String formSceneUuid = configObj.getString("formSceneUuid"); - String formSceneName = configObj.getString("formSceneName"); - resultObj.put("formSceneUuid", formSceneUuid == null ? "" : formSceneUuid); - resultObj.put("formSceneName", formSceneName == null ? "" : formSceneName); - return resultObj; - } - - private CiEntitySyncVo regulateCiEntityConfig(JSONObject ciEntityConfig) { - CiEntitySyncVo ciEntitySyncVo = new CiEntitySyncVo(); - if (ciEntityConfig != null) { - ciEntitySyncVo = ciEntityConfig.toJavaObject(CiEntitySyncVo.class); - } - // 失败策略 - String failPolicy = ciEntitySyncVo.getFailPolicy(); - if (failPolicy == null) { - if (ciEntityConfig != null) { - logger.warn("ciEntityConfig.failPolicy is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.failPolicy is null"); - } - ciEntitySyncVo.setFailPolicy(StringUtils.EMPTY); - } - // 回退步骤重新同步 - Integer rerunStepToSync = ciEntitySyncVo.getRerunStepToSync(); - if (rerunStepToSync == null) { - if (ciEntityConfig != null) { - logger.warn("ciEntityConfig.rerunStepToSync is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.rerunStepToSync is null"); - } - ciEntitySyncVo.setRerunStepToSync(0); - } - List configList = ciEntitySyncVo.getConfigList(); - if (CollectionUtils.isEmpty(configList)) { - if (ciEntityConfig != null) { - logger.warn("ciEntityConfig.configList is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList is null"); - } - return ciEntitySyncVo; - } - Iterator iterator = configList.iterator(); - while (iterator.hasNext()) { - CiEntitySyncConfigVo configObj = iterator.next(); - if (configObj == null) { - iterator.remove(); - continue; - } - if (configObj.getId() != null) { - logger.warn("ciEntityConfig.configList[x].id is not null"); - configObj.setId(null); - } - String ciName = configObj.getCiName(); - if (StringUtils.isBlank(ciName)) { - logger.warn("ciEntityConfig.configList[x].ciName is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].ciName is null"); - } - String name = ciName; - String ciLabel = configObj.getCiLabel(); - if (StringUtils.isBlank(ciLabel)) { - logger.warn("ciEntityConfig.configList[" + name + "].ciLabel is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciLabel is null"); - } - name += "(" + ciLabel + ")"; - if (StringUtils.isBlank(configObj.getUuid())) { - logger.warn("ciEntityConfig.configList[" + name + "].uuid is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].uuid is null"); - } - if (configObj.getCiId() == null) { - logger.warn("ciEntityConfig.configList[" + name + "].ciId is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciId is null"); - } - if (StringUtils.isBlank(configObj.getCiIcon())) { - logger.warn("ciEntityConfig.configList[" + name + "].ciIcon is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciIcon is null"); - } - String createPolicy = configObj.getCreatePolicy(); - if (StringUtils.isBlank(createPolicy)) { - logger.warn("ciEntityConfig.configList[" + name + "].createPolicy is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].createPolicy is null"); - } - CiEntitySyncBatchDataSourceVo batchDataSource = configObj.getBatchDataSource(); - if (Objects.equals(createPolicy, "single")) { - if (batchDataSource != null) { - if (StringUtils.isNotBlank(batchDataSource.getAttributeUuid())) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is not null"); - } - List filterList = batchDataSource.getFilterList(); - if (CollectionUtils.isNotEmpty(filterList)) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList is not null"); - } - } - } else if (Objects.equals(createPolicy, "batch")) { - if (batchDataSource == null) { - logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource is null"); - throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource is null"); - } - if (StringUtils.isBlank(batchDataSource.getAttributeUuid())) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is null"); - } - String type = batchDataSource.getType(); - if (StringUtils.isBlank(type)) { - logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type is null"); - throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type is null"); - } else if (!Objects.equals(type, "formSubassemblyComponent") && !Objects.equals(type, "formTableComponent")) { - logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type = " + type + " is not valid"); - throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type = " + type + " is not valid"); - } - List filterList = batchDataSource.getFilterList(); - if (CollectionUtils.isNotEmpty(filterList)) { - Iterator filterIterator = filterList.iterator(); - while (filterIterator.hasNext()) { - CiEntitySyncFilterVo filterVo = filterIterator.next(); - if (filterVo == null) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y] is null"); - filterIterator.remove(); - continue; - } - if (StringUtils.isBlank(filterVo.getColumn())) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].column is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].column is null"); - } - if (StringUtils.isBlank(filterVo.getExpression())) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].expression is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].expression is null"); - } - if (StringUtils.isBlank(filterVo.getValue())) { - logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].value is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].value is null"); - } - } - } - } - - List mappingList = configObj.getMappingList(); - if (CollectionUtils.isEmpty(mappingList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList is null"); - continue; - } - Iterator mappingIterator = mappingList.iterator(); - while (mappingIterator.hasNext()) { - CiEntitySyncMappingVo mappingVo = mappingIterator.next(); - if (mappingVo == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y] is null"); - mappingIterator.remove(); - continue; - } - if (StringUtils.isBlank(mappingVo.getKey())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].key is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].key is null"); - } - String mappingMode = mappingVo.getMappingMode(); - if (StringUtils.isBlank(mappingMode)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].mappingMode is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].mappingMode is null"); - } - JSONArray valueList = mappingVo.getValueList(); - List filterList = mappingVo.getFilterList(); - if (Objects.equals(mappingMode, "formSubassemblyComponent")) { - if (CollectionUtils.isEmpty(valueList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - } - if (valueList.get(0) == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - } - if (CollectionUtils.isNotEmpty(filterList)) { - Iterator filterIterator = filterList.iterator(); - while (filterIterator.hasNext()) { - CiEntitySyncFilterVo filterVo = filterIterator.next(); - if (filterVo == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z] is null"); - filterIterator.remove(); - continue; - } - if (StringUtils.isBlank(filterVo.getColumn())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); - } - if (StringUtils.isBlank(filterVo.getExpression())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); - } - if (StringUtils.isBlank(filterVo.getValue())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); - } - } - } - } else if (Objects.equals(mappingMode, "formTableComponent")) { - if (CollectionUtils.isEmpty(valueList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - } - if (valueList.get(0) == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - } - if (CollectionUtils.isNotEmpty(filterList)) { - Iterator filterIterator = filterList.iterator(); - while (filterIterator.hasNext()) { - CiEntitySyncFilterVo filterVo = filterIterator.next(); - if (filterVo == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z] is null"); - filterIterator.remove(); - continue; - } - if (StringUtils.isBlank(filterVo.getColumn())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); - } - if (StringUtils.isBlank(filterVo.getExpression())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); - } - if (StringUtils.isBlank(filterVo.getValue())) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); - } - } - } - } else if (Objects.equals(mappingMode, "formCommonComponent")) { - if (CollectionUtils.isEmpty(valueList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - } - for (int i = 0; i < valueList.size(); i++) { - if (valueList.get(i) == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z] is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z] is null"); - } - } - if (CollectionUtils.isNotEmpty(filterList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); - mappingVo.setFilterList(null); - } - } else if (Objects.equals(mappingMode, "constant")) { - if (CollectionUtils.isNotEmpty(filterList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); - mappingVo.setFilterList(null); - } - } else if (Objects.equals(mappingMode, "new")) { - if (CollectionUtils.isEmpty(valueList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); - } else { - if (valueList.get(0) == null) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); - } - } - if (CollectionUtils.isNotEmpty(filterList)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); - mappingVo.setFilterList(null); - } - } - } - -// JSONArray children = configObj.getChildren(); -// if (CollectionUtils.isEmpty(children)) { +// @SuppressWarnings("serial") +// @Override +// public JSONObject makeupConfig(JSONObject configObj) { +// if (configObj == null) { +// configObj = new JSONObject(); +// } +// JSONObject resultObj = new JSONObject(); +// +// /** 授权 **/ +// IOperationType[] stepActions = { +// ProcessTaskStepOperationType.STEP_VIEW, +// ProcessTaskStepOperationType.STEP_TRANSFER +// }; +// JSONArray authorityList = configObj.getJSONArray("authorityList"); +// JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); +// resultObj.put("authorityList", authorityArray); +// +// /* 按钮映射 **/ +// IOperationType[] stepButtons = { +// ProcessTaskStepOperationType.STEP_COMPLETE, +// ProcessTaskStepOperationType.STEP_BACK, +// ProcessTaskOperationType.PROCESSTASK_TRANSFER, +// ProcessTaskStepOperationType.STEP_ACCEPT +// }; +// JSONArray customButtonList = configObj.getJSONArray("customButtonList"); +// JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); +// resultObj.put("customButtonList", customButtonArray); +// +// /* 状态映射列表 **/ +// JSONArray customStatusList = configObj.getJSONArray("customStatusList"); +// JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); +// resultObj.put("customStatusList", customStatusArray); +// +// /* 可替换文本列表 **/ +// resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); +// return resultObj; +// } + +// @Override +// public JSONObject regulateProcessStepConfig(JSONObject configObj) { +// if (configObj == null) { +// configObj = new JSONObject(); +// } +// JSONObject resultObj = new JSONObject(); +// +// /* 授权 **/ +// IOperationType[] stepActions = { +// ProcessTaskStepOperationType.STEP_VIEW, +// ProcessTaskStepOperationType.STEP_TRANSFER +// }; +// JSONArray authorityList = null; +// Integer enableAuthority = configObj.getInteger("enableAuthority"); +// if (Objects.equals(enableAuthority, 1)) { +// authorityList = configObj.getJSONArray("authorityList"); +// } else { +// enableAuthority = 0; +// } +// resultObj.put("enableAuthority", enableAuthority); +// JSONArray authorityArray = ProcessConfigUtil.regulateAuthorityList(authorityList, stepActions); +// resultObj.put("authorityList", authorityArray); +// +// /** 通知 **/ +// JSONObject notifyPolicyConfig = configObj.getJSONObject("notifyPolicyConfig"); +// INotifyServiceCrossoverService notifyServiceCrossoverService = CrossoverServiceFactory.getApi(INotifyServiceCrossoverService.class); +// InvokeNotifyPolicyConfigVo invokeNotifyPolicyConfigVo = notifyServiceCrossoverService.regulateNotifyPolicyConfig(notifyPolicyConfig, CmdbSyncNotifyHandler.class); +// resultObj.put("notifyPolicyConfig", invokeNotifyPolicyConfigVo); +// +// /** 动作 **/ +// JSONObject actionConfig = configObj.getJSONObject("actionConfig"); +// ActionConfigVo actionConfigVo = JSONObject.toJavaObject(actionConfig, ActionConfigVo.class); +// if (actionConfigVo == null) { +// actionConfigVo = new ActionConfigVo(); +// } +// actionConfigVo.setHandler(CmdbSyncNotifyHandler.class.getName()); +// resultObj.put("actionConfig", actionConfigVo); +// +// JSONArray customButtonList = configObj.getJSONArray("customButtonList"); +// /* 按钮映射列表 **/ +// IOperationType[] stepButtons = { +// ProcessTaskStepOperationType.STEP_COMPLETE, +// ProcessTaskStepOperationType.STEP_BACK, +// ProcessTaskOperationType.PROCESSTASK_TRANSFER, +// ProcessTaskStepOperationType.STEP_ACCEPT +// }; +// +// JSONArray customButtonArray = ProcessConfigUtil.regulateCustomButtonList(customButtonList, stepButtons); +// resultObj.put("customButtonList", customButtonArray); +// /* 状态映射列表 **/ +// JSONArray customStatusList = configObj.getJSONArray("customStatusList"); +// JSONArray customStatusArray = ProcessConfigUtil.regulateCustomStatusList(customStatusList); +// resultObj.put("customStatusList", customStatusArray); +// +// /* 可替换文本列表 **/ +// resultObj.put("replaceableTextList", ProcessConfigUtil.regulateReplaceableTextList(configObj.getJSONArray("replaceableTextList"))); +// +// /* 自动化配置 **/ +// JSONObject ciEntityConfig = configObj.getJSONObject("ciEntityConfig"); +// CiEntitySyncVo ciEntitySyncVo = regulateCiEntityConfig(ciEntityConfig); +// resultObj.put("ciEntityConfig", ciEntitySyncVo); +// +// /* 分配处理人 **/ +// JSONObject workerPolicyConfig = configObj.getJSONObject("workerPolicyConfig"); +// JSONObject workerPolicyObj = ProcessConfigUtil.regulateWorkerPolicyConfig(workerPolicyConfig); +// resultObj.put("workerPolicyConfig", workerPolicyObj); +// +// JSONObject simpleSettings = ProcessConfigUtil.regulateSimpleSettings(configObj); +// resultObj.putAll(simpleSettings); +// /* 表单场景 **/ +// String formSceneUuid = configObj.getString("formSceneUuid"); +// String formSceneName = configObj.getString("formSceneName"); +// resultObj.put("formSceneUuid", formSceneUuid == null ? "" : formSceneUuid); +// resultObj.put("formSceneName", formSceneName == null ? "" : formSceneName); +// return resultObj; +// } + +// private CiEntitySyncVo regulateCiEntityConfig(JSONObject ciEntityConfig) { +// CiEntitySyncVo ciEntitySyncVo = new CiEntitySyncVo(); +// if (ciEntityConfig != null) { +// ciEntitySyncVo = ciEntityConfig.toJavaObject(CiEntitySyncVo.class); +// } +// // 失败策略 +// String failPolicy = ciEntitySyncVo.getFailPolicy(); +// if (failPolicy == null) { +// if (ciEntityConfig != null) { +// logger.warn("ciEntityConfig.failPolicy is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.failPolicy is null"); +// } +// ciEntitySyncVo.setFailPolicy(StringUtils.EMPTY); +// } +// // 回退步骤重新同步 +// Integer rerunStepToSync = ciEntitySyncVo.getRerunStepToSync(); +// if (rerunStepToSync == null) { +// if (ciEntityConfig != null) { +// logger.warn("ciEntityConfig.rerunStepToSync is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.rerunStepToSync is null"); +// } +// ciEntitySyncVo.setRerunStepToSync(0); +// } +// List configList = ciEntitySyncVo.getConfigList(); +// if (CollectionUtils.isEmpty(configList)) { +// if (ciEntityConfig != null) { +// logger.warn("ciEntityConfig.configList is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList is null"); +// } +// return ciEntitySyncVo; +// } +// Iterator iterator = configList.iterator(); +// while (iterator.hasNext()) { +// CiEntitySyncConfigVo configObj = iterator.next(); +// if (configObj == null) { +// iterator.remove(); +// continue; +// } +// if (configObj.getId() != null) { +// logger.warn("ciEntityConfig.configList[x].id is not null"); +// configObj.setId(null); +// } +// String ciName = configObj.getCiName(); +// if (StringUtils.isBlank(ciName)) { +// logger.warn("ciEntityConfig.configList[x].ciName is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].ciName is null"); +// } +// String name = ciName; +// String ciLabel = configObj.getCiLabel(); +// if (StringUtils.isBlank(ciLabel)) { +// logger.warn("ciEntityConfig.configList[" + name + "].ciLabel is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciLabel is null"); +// } +// name += "(" + ciLabel + ")"; +// if (StringUtils.isBlank(configObj.getUuid())) { +// logger.warn("ciEntityConfig.configList[" + name + "].uuid is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].uuid is null"); +// } +// if (configObj.getCiId() == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].ciId is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciId is null"); +// } +// if (StringUtils.isBlank(configObj.getCiIcon())) { +// logger.warn("ciEntityConfig.configList[" + name + "].ciIcon is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].ciIcon is null"); +// } +// String createPolicy = configObj.getCreatePolicy(); +// if (StringUtils.isBlank(createPolicy)) { +// logger.warn("ciEntityConfig.configList[" + name + "].createPolicy is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].createPolicy is null"); +// } +// CiEntitySyncBatchDataSourceVo batchDataSource = configObj.getBatchDataSource(); +// if (Objects.equals(createPolicy, "single")) { +// if (batchDataSource != null) { +// if (StringUtils.isNotBlank(batchDataSource.getAttributeUuid())) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is not null"); +// } +// List filterList = batchDataSource.getFilterList(); +// if (CollectionUtils.isNotEmpty(filterList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList is not null"); +// } +// } +// } else if (Objects.equals(createPolicy, "batch")) { +// if (batchDataSource == null) { +// logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource is null"); +// throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource is null"); +// } +// if (StringUtils.isBlank(batchDataSource.getAttributeUuid())) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.attributeUuid is null"); +// } +// String type = batchDataSource.getType(); +// if (StringUtils.isBlank(type)) { +// logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type is null"); +// throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type is null"); +// } else if (!Objects.equals(type, "formSubassemblyComponent") && !Objects.equals(type, "formTableComponent")) { +// logger.warn("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type = " + type + " is not valid"); +// throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[" + name + "].batchDataSource.type = " + type + " is not valid"); +// } +// List filterList = batchDataSource.getFilterList(); +// if (CollectionUtils.isNotEmpty(filterList)) { +// Iterator filterIterator = filterList.iterator(); +// while (filterIterator.hasNext()) { +// CiEntitySyncFilterVo filterVo = filterIterator.next(); +// if (filterVo == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y] is null"); +// filterIterator.remove(); +// continue; +// } +// if (StringUtils.isBlank(filterVo.getColumn())) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].column is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].column is null"); +// } +// if (StringUtils.isBlank(filterVo.getExpression())) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].expression is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].expression is null"); +// } +// if (StringUtils.isBlank(filterVo.getValue())) { +// logger.warn("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].value is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].batchDataSource.filterList[y].value is null"); +// } +// } +// } +// } +// +// List mappingList = configObj.getMappingList(); +// if (CollectionUtils.isEmpty(mappingList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList is null"); // continue; // } -// for (int i = children.size() - 1; i >= 0; i--) { -// JSONObject child = children.getJSONObject(i); -// if (MapUtils.isEmpty(child)) { -// logger.warn("ciEntityConfig.configList[" + name + "].children[i] is null"); -// children.remove(i); +// Iterator mappingIterator = mappingList.iterator(); +// while (mappingIterator.hasNext()) { +// CiEntitySyncMappingVo mappingVo = mappingIterator.next(); +// if (mappingVo == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y] is null"); +// mappingIterator.remove(); // continue; // } -// String ciEntityUuid = child.getString("ciEntityUuid"); -// if (StringUtils.isBlank(ciEntityUuid)) { -// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid is null"); -// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid is null"); +// if (StringUtils.isBlank(mappingVo.getKey())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].key is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].key is null"); // } -// String ciEntityName = child.getString("ciEntityName"); -// if (StringUtils.isBlank(ciEntityName)) { -// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityName is null"); -// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityName is null"); +// String mappingMode = mappingVo.getMappingMode(); +// if (StringUtils.isBlank(mappingMode)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].mappingMode is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].mappingMode is null"); // } -// Long ciId = child.getLong("ciId"); -// if (ciId == null) { -// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciId is null"); -// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciId is null"); +// JSONArray valueList = mappingVo.getValueList(); +// List filterList = mappingVo.getFilterList(); +// if (Objects.equals(mappingMode, "formSubassemblyComponent")) { +// if (CollectionUtils.isEmpty(valueList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// } +// if (valueList.get(0) == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// } +// if (CollectionUtils.isNotEmpty(filterList)) { +// Iterator filterIterator = filterList.iterator(); +// while (filterIterator.hasNext()) { +// CiEntitySyncFilterVo filterVo = filterIterator.next(); +// if (filterVo == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z] is null"); +// filterIterator.remove(); +// continue; +// } +// if (StringUtils.isBlank(filterVo.getColumn())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); +// } +// if (StringUtils.isBlank(filterVo.getExpression())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); +// } +// if (StringUtils.isBlank(filterVo.getValue())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); +// } +// } +// } +// } else if (Objects.equals(mappingMode, "formTableComponent")) { +// if (CollectionUtils.isEmpty(valueList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// } +// if (valueList.get(0) == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// } +// if (CollectionUtils.isNotEmpty(filterList)) { +// Iterator filterIterator = filterList.iterator(); +// while (filterIterator.hasNext()) { +// CiEntitySyncFilterVo filterVo = filterIterator.next(); +// if (filterVo == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z] is null"); +// filterIterator.remove(); +// continue; +// } +// if (StringUtils.isBlank(filterVo.getColumn())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].column is null"); +// } +// if (StringUtils.isBlank(filterVo.getExpression())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].expression is null"); +// } +// if (StringUtils.isBlank(filterVo.getValue())) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].filterList[z].value is null"); +// } +// } +// } +// } else if (Objects.equals(mappingMode, "formCommonComponent")) { +// if (CollectionUtils.isEmpty(valueList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// } +// for (int i = 0; i < valueList.size(); i++) { +// if (valueList.get(i) == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z] is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z] is null"); +// } +// } +// if (CollectionUtils.isNotEmpty(filterList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); +// mappingVo.setFilterList(null); +// } +// } else if (Objects.equals(mappingMode, "constant")) { +// if (CollectionUtils.isNotEmpty(filterList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); +// mappingVo.setFilterList(null); +// } +// } else if (Objects.equals(mappingMode, "new")) { +// if (CollectionUtils.isEmpty(valueList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList is null"); +// } else { +// if (valueList.get(0) == null) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[0] is null"); +// } +// } +// if (CollectionUtils.isNotEmpty(filterList)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].filterList is not null"); +// mappingVo.setFilterList(null); +// } // } // } - } - - Set usedUuidList = new HashSet<>(); - List allUuidList = configList.stream().map(CiEntitySyncConfigVo::getUuid).collect(Collectors.toList()); - for (CiEntitySyncConfigVo ciEntitySyncConfigVo : configList) { - String ciName = ciEntitySyncConfigVo.getCiName(); - String name = ciName; - String ciLabel = ciEntitySyncConfigVo.getCiLabel(); - name += "(" + ciLabel + ")"; -// JSONArray children = ciEntitySyncConfigVo.getChildren(); -// if (CollectionUtils.isNotEmpty(children)) { -// for (int i = 0; i < children.size(); i++) { -// JSONObject child = children.getJSONObject(i); -// String ciEntityUuid = child.getString("ciEntityUuid"); -// if (!allUuidList.contains(ciEntityUuid)) { -// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); -// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); +// +//// JSONArray children = configObj.getChildren(); +//// if (CollectionUtils.isEmpty(children)) { +//// continue; +//// } +//// for (int i = children.size() - 1; i >= 0; i--) { +//// JSONObject child = children.getJSONObject(i); +//// if (MapUtils.isEmpty(child)) { +//// logger.warn("ciEntityConfig.configList[" + name + "].children[i] is null"); +//// children.remove(i); +//// continue; +//// } +//// String ciEntityUuid = child.getString("ciEntityUuid"); +//// if (StringUtils.isBlank(ciEntityUuid)) { +//// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid is null"); +//// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid is null"); +//// } +//// String ciEntityName = child.getString("ciEntityName"); +//// if (StringUtils.isBlank(ciEntityName)) { +//// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityName is null"); +//// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityName is null"); +//// } +//// Long ciId = child.getLong("ciId"); +//// if (ciId == null) { +//// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciId is null"); +//// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciId is null"); +//// } +//// } +// } +// +// Set usedUuidList = new HashSet<>(); +// List allUuidList = configList.stream().map(CiEntitySyncConfigVo::getUuid).collect(Collectors.toList()); +// for (CiEntitySyncConfigVo ciEntitySyncConfigVo : configList) { +// String ciName = ciEntitySyncConfigVo.getCiName(); +// String name = ciName; +// String ciLabel = ciEntitySyncConfigVo.getCiLabel(); +// name += "(" + ciLabel + ")"; +//// JSONArray children = ciEntitySyncConfigVo.getChildren(); +//// if (CollectionUtils.isNotEmpty(children)) { +//// for (int i = 0; i < children.size(); i++) { +//// JSONObject child = children.getJSONObject(i); +//// String ciEntityUuid = child.getString("ciEntityUuid"); +//// if (!allUuidList.contains(ciEntityUuid)) { +//// logger.warn("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); +//// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].children[i].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); +//// } +//// usedUuidList.add(ciEntityUuid); +//// } +//// } +// List mappingList = ciEntitySyncConfigVo.getMappingList(); +// if (CollectionUtils.isNotEmpty(mappingList)) { +// for (CiEntitySyncMappingVo mapping : mappingList) { +// if (Objects.equals(mapping.getMappingMode(), "new")) { +// JSONArray valueList = mapping.getValueList(); +// for (int i = 0; i < valueList.size(); i++) { +// JSONObject valueObj = valueList.getJSONObject(i); +// String type = valueObj.getString("type"); +// if (!Objects.equals(type, "new")) { +// continue; +// } +// String ciEntityUuid = valueObj.getString("ciEntityUuid"); +// if (!allUuidList.contains(ciEntityUuid)) { +// logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); +// throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); +// } +// usedUuidList.add(ciEntityUuid); +// } // } -// usedUuidList.add(ciEntityUuid); // } // } - List mappingList = ciEntitySyncConfigVo.getMappingList(); - if (CollectionUtils.isNotEmpty(mappingList)) { - for (CiEntitySyncMappingVo mapping : mappingList) { - if (Objects.equals(mapping.getMappingMode(), "new")) { - JSONArray valueList = mapping.getValueList(); - for (int i = 0; i < valueList.size(); i++) { - JSONObject valueObj = valueList.getJSONObject(i); - String type = valueObj.getString("type"); - if (!Objects.equals(type, "new")) { - continue; - } - String ciEntityUuid = valueObj.getString("ciEntityUuid"); - if (!allUuidList.contains(ciEntityUuid)) { - logger.warn("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); - throw new CiEntityConfigIllegalException("ciEntityConfig.configList[" + name + "].mappingList[y].valueList[z].ciEntityUuid = '" + ciEntityUuid + "' is illegal"); - } - usedUuidList.add(ciEntityUuid); - } - } - } - } - } - allUuidList.removeAll(usedUuidList); - if (CollectionUtils.isNotEmpty(allUuidList)) { - for (int i = configList.size() - 1; i >= 0; i--) { - CiEntitySyncConfigVo ciEntitySyncConfigVo = configList.get(i); - if (allUuidList.contains(ciEntitySyncConfigVo.getUuid()) && !Objects.equals(ciEntitySyncConfigVo.getIsStart(), 1)) { - logger.warn("ciEntitySyncConfig is not used:" + JSONObject.toJSONString(ciEntitySyncConfigVo)); - configList.remove(i); - } - } - } - return ciEntitySyncVo; - } +// } +// allUuidList.removeAll(usedUuidList); +// if (CollectionUtils.isNotEmpty(allUuidList)) { +// for (int i = configList.size() - 1; i >= 0; i--) { +// CiEntitySyncConfigVo ciEntitySyncConfigVo = configList.get(i); +// if (allUuidList.contains(ciEntitySyncConfigVo.getUuid()) && !Objects.equals(ciEntitySyncConfigVo.getIsStart(), 1)) { +// logger.warn("ciEntitySyncConfig is not used:" + JSONObject.toJSONString(ciEntitySyncConfigVo)); +// configList.remove(i); +// } +// } +// } +// return ciEntitySyncVo; +// } } diff --git a/src/main/java/neatlogic/module/cmdb/process/stephandler/regulate/HandlerListRegulateHandler.java b/src/main/java/neatlogic/module/cmdb/process/stephandler/regulate/HandlerListRegulateHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..03f7c18244d208f51d11e2dd6230c5d19263143d --- /dev/null +++ b/src/main/java/neatlogic/module/cmdb/process/stephandler/regulate/HandlerListRegulateHandler.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2024 深圳极向量科技有限公司 All Rights Reserved. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package neatlogic.module.cmdb.process.stephandler.regulate; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import neatlogic.framework.process.stephandler.core.IProcessStepInternalHandler; +import neatlogic.framework.process.stephandler.core.IRegulateHandler; +import org.springframework.stereotype.Service; + +@Service +public class HandlerListRegulateHandler implements IRegulateHandler { + @Override + public String getName() { + return "handlerList"; + } + + @Override + public void regulateConfig(IProcessStepInternalHandler processStepInternalHandler, JSONObject oldConfigObj, JSONObject newConfigObj) { + /** 关联表单组件 **/ + JSONArray handlerList = oldConfigObj.getJSONArray("handlerList"); + if (handlerList == null) { + handlerList = new JSONArray(); + } + newConfigObj.put("handlerList", handlerList); + } +}