diff --git a/src/main/java/neatlogic/module/cmdb/process/dto/CiEntitySyncBatchDataSourceVo.java b/src/main/java/neatlogic/module/cmdb/process/dto/CiEntitySyncBatchDataSourceVo.java index 933002cb5ef5c85ab3d13b99d8a7ea38ab2492b2..455f6fdbb2191fb01058be586a5872ce79f1b53b 100644 --- a/src/main/java/neatlogic/module/cmdb/process/dto/CiEntitySyncBatchDataSourceVo.java +++ b/src/main/java/neatlogic/module/cmdb/process/dto/CiEntitySyncBatchDataSourceVo.java @@ -4,6 +4,7 @@ import java.util.List; public class CiEntitySyncBatchDataSourceVo { private String attributeUuid; + private String type; private List filterList; public String getAttributeUuid() { @@ -14,6 +15,14 @@ public class CiEntitySyncBatchDataSourceVo { this.attributeUuid = attributeUuid; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + public List getFilterList() { return filterList; } 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 3e0621c124c44a5c52df1cf6e683c3b968180a02..46b42b9047e8261ff00b07d8d51ebb4906fab7cb 100644 --- a/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java +++ b/src/main/java/neatlogic/module/cmdb/process/stephandler/CmdbSyncProcessUtilHandler.java @@ -386,6 +386,14 @@ public class CmdbSyncProcessUtilHandler extends ProcessStepInternalHandlerBase { logger.warn("ciEntityConfig.configList[x].batchDataSource.attributeUuid is null"); throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].batchDataSource.attributeUuid is null"); } + String type = batchDataSource.getType(); + if (StringUtils.isBlank(type)) { + logger.warn("createPolicy = batch, ciEntityConfig.configList[x].batchDataSource.type is null"); + throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[x].batchDataSource.type is null"); + } else if (!Objects.equals(type, "formSubassemblyComponent") && !Objects.equals(type, "formTableComponent")) { + logger.warn("createPolicy = batch, ciEntityConfig.configList[x].batchDataSource.type = " + type + " is not valid"); + throw new CiEntityConfigIllegalException("createPolicy = batch, ciEntityConfig.configList[x].batchDataSource.type = " + type + " is not valid"); + } List filterList = batchDataSource.getFilterList(); if (CollectionUtils.isNotEmpty(filterList)) { Iterator filterIterator = filterList.iterator(); @@ -438,7 +446,43 @@ public class CmdbSyncProcessUtilHandler extends ProcessStepInternalHandlerBase { JSONArray valueList = mappingVo.getValueList(); String column = mappingVo.getColumn(); List filterList = mappingVo.getFilterList(); - if (Objects.equals(mappingMode, "formTableComponent")) { + if (Objects.equals(mappingMode, "formSubassemblyComponent")) { + if (CollectionUtils.isEmpty(valueList)) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].valueList is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].valueList is null"); + } + if (valueList.get(0) == null) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].valueList[0] is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].valueList[0] is null"); + } + if (StringUtils.isBlank(column)) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].column is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].column is null"); + } + if (CollectionUtils.isNotEmpty(filterList)) { + Iterator filterIterator = filterList.iterator(); + while (filterIterator.hasNext()) { + CiEntitySyncFilterVo filterVo = filterIterator.next(); + if (filterVo == null) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].filterList[z] is null"); + filterIterator.remove(); + continue; + } + if (StringUtils.isBlank(filterVo.getColumn())) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].filterList[z].column is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].filterList[z].column is null"); + } + if (StringUtils.isBlank(filterVo.getExpression())) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].filterList[z].expression is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].filterList[z].expression is null"); + } + if (StringUtils.isBlank(filterVo.getValue())) { + logger.warn("ciEntityConfig.configList[x].mappingList[y].filterList[z].value is null"); + throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].filterList[z].value is null"); + } + } + } + } else if (Objects.equals(mappingMode, "formTableComponent")) { if (CollectionUtils.isEmpty(valueList)) { logger.warn("ciEntityConfig.configList[x].mappingList[y].valueList is null"); throw new CiEntityConfigIllegalException("ciEntityConfig.configList[x].mappingList[y].valueList is null");