diff --git a/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar b/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar index a8dce7d6..7032c7c8 100644 Binary files a/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar and b/com.actionsoft.apps.coe.pal.batch/lib/com.actionsoft.apps.coe.pal.batch.jar differ diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/process/valid/impl/type/ValidRelation.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/process/valid/impl/type/ValidRelation.java index b3750aa9..0bd6d276 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/process/valid/impl/type/ValidRelation.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/process/valid/impl/type/ValidRelation.java @@ -1,11 +1,6 @@ package com.actionsoft.apps.coe.pal.batch.web.create.process.valid.impl.type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.batch.util.BatchUtil; @@ -78,81 +73,43 @@ public class ValidRelation implements ValidCell { isOk = false; msg = "单选属性不支持多个值"; } else { - for (String path : valueSet) { - String [] pathArr = path.split("/"); - boolean flag = true; - List tmpList = new ArrayList(); - for (int j = 0; j < pathArr.length; j++) { - if (UtilString.isEmpty(pathArr[j])) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - if (j == 0) {// 寻找流程大类是否存在 - if (!pathArr[j].equals(I18nRes.findValue(CoEConstant.APP_ID, category))) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList.add(category); - } else { - // 获取子节点 - List tmpList2 = new ArrayList(); - for (String pid : tmpList) { - List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(pathArr[j])) { - if (j == pathArr.length - 1) { - if ("default".equals(model.getMethodId())) { - isOk = false; - msg = "路径[" + path + "]末级流程不允许是文件夹"; - flag = false; - break; - } else if (!model.getMethodId().contains(method)) { - isOk = false; - msg = "路径[" + path + "]末级流程不符合属性范围要求"; - } else { - tmpList2.add(model.getId()); - } - } else { - tmpList2.add(model.getId()); - } - } - } - if (!flag) { - break; - } - } - if (flag && tmpList2.size() == 0) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList = tmpList2; + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + Map map = new HashMap<>(); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (model.isUse()) { + map.put(model.getId(), model.getName().trim()); + } + } + for (String name : valueSet) { + List ids = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (name.equals(entry.getValue())) { + ids.add(entry.getKey()); } } - if (flag) { - if (tmpList.size() == 0) { + if (ids.size() == 0) { + isOk = false; + msg = "[" + name + "]不存在"; + break; + } if (ids.size() > 1) { + isOk = false; + msg = "[" + name + "]出现多个匹配"; + break; + } else { + PALRepositoryModel model = PALRepositoryCache.getCache().get(ids.get(0)); + if ("default".equals(model.getMethodId())) { isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不允许是文件夹"; break; - } else if (tmpList.size() > 1) { + } else if (!model.getMethodId().contains(method)) { isOk = false; - msg = "路径[" + path + "]存在多个,无法匹配"; - break; - } else if (tmpList.get(0).length() < 36) { - isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不符合属性范围要求"; break; } else { isOk = true; - repositoryIds.add(tmpList.get(0)); + repositoryIds.add(model.getId()); } - } else { - break; } } } @@ -169,7 +126,7 @@ public class ValidRelation implements ValidCell { } } attr.put("relations", result); - } else {// 关联的是形状 + } else if ("shape".equals(type)) {// 关联的是形状 Set fileShapeIds = new HashSet<>(); String [] valueArr = value.split(","); // 过滤掉空值 @@ -183,108 +140,70 @@ public class ValidRelation implements ValidCell { isOk = false; msg = "单选属性不支持多个值"; } else { - for (String path : valueSet) { - String [] pathArr = path.split("/"); - boolean flag = true; - List tmpList = new ArrayList(); - for (int j = 0; j < pathArr.length; j++) { - if (UtilString.isEmpty(pathArr[j])) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - if (j == 0) {// 寻找流程大类是否存在 - if (!pathArr[j].equals(I18nRes.findValue(CoEConstant.APP_ID, category))) { - isOk = false; - msg = "大类路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList.add(category); - } else { - // 获取子节点 - List tmpList2 = new ArrayList(); - for (String pid : tmpList) { - List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - String repositoryName = null; - String shapeName = null; - if (j == pathArr.length - 1) { - // 拆分名称为名称+节点名称 - String [] namePath = pathArr[j].split(":"); - if (namePath.length == 2 && !UtilString.isEmpty(namePath[0]) && !UtilString.isEmpty(namePath[1])) { - repositoryName = namePath[0]; - shapeName = namePath[1]; - } else { - isOk = false; - msg = "路径[" + path + "]末级流程与节点信息错误"; - flag = false; - break; - } - } - if (j == pathArr.length - 1) {// 最后一个层级 - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(repositoryName)) { - if ("default".equals(model.getMethodId())) { - isOk = false; - msg = "路径[" + path + "]末级流程不允许是文件夹"; - flag = false; - break; - } else if (!model.getMethodId().contains(method)) { - isOk = false; - msg = "路径[" + path + "]末级流程不符合属性范围要求"; - } else { - // 获取节点数据 - String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId()); - List shapes = ShapeUtil.getShapeJsonToJsonObject(definition); - for (JSONObject shape : shapes) { - if (shapeName.equals(shape.getString("text"))) { - // 获取匹配的节点数据 - tmpList2.add(model.getId() + ":" + shape.getString("id") + ":" + shape.getString("text")); - } - } - } - } - } - } else { - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(pathArr[j])) { - tmpList2.add(model.getId()); - } - } - } - if (!flag) { - break; - } - } - if (flag && tmpList2.size() == 0) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList = tmpList2; + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + Map map = new HashMap<>(); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (model.isUse()) { + map.put(model.getId(), model.getName().trim()); + } + } + for (String nameArr : valueSet) { + // 拆分名称为名称+节点名称 + String name = null; + String shapeName = null; + String [] namePath = nameArr.split(":"); + if (namePath.length == 2 && !UtilString.isEmpty(namePath[0]) && !UtilString.isEmpty(namePath[1])) { + name = namePath[0]; + shapeName = namePath[1]; + } else { + isOk = false; + msg = "[" + nameArr + "]末级模型与节点信息错误"; + break; + } + List ids = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (name.equals(entry.getValue())) { + ids.add(entry.getKey()); } } - if (flag) { - if (tmpList.size() == 0) { + if (ids.size() == 0) { + isOk = false; + msg = "[" + name + "]不存在"; + break; + } if (ids.size() > 1) { + isOk = false; + msg = "[" + name + "]出现多个匹配"; + break; + } else { + PALRepositoryModel model = PALRepositoryCache.getCache().get(ids.get(0)); + if ("default".equals(model.getMethodId())) { isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不允许是文件夹"; break; - } else if (tmpList.size() > 1) { + } else if (!model.getMethodId().contains(method)) { isOk = false; - msg = "路径[" + path + "]存在多个,无法匹配"; - break; - } else if (tmpList.get(0).length() < 36) { - isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不符合属性范围要求"; break; } else { + String result = null; + // 获取节点数据 + String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId()); + List shapes = ShapeUtil.getShapeJsonToJsonObject(definition); + for (JSONObject shape : shapes) { + if (shapeName.equals(shape.getString("text"))) { + // 获取匹配的节点数据 + result = model.getId() + ":" + shape.getString("id") + ":" + shape.getString("text"); + } + } + if (result == null) { + isOk = false; + msg = "[" + shapeName + "]不存在"; + break; + } isOk = true; - fileShapeIds.add(tmpList.get(0)); + fileShapeIds.add(result); } - } else { - break; } } } @@ -300,6 +219,8 @@ public class ValidRelation implements ValidCell { shapes.add(object); } attr.put("relations", shapes); + } else { + msg = "不支持形状和模型同时选择的类型"; } JSONObject result = new JSONObject(); result.put("name", title); diff --git a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/valid/impl/type/ValidShapeRelation.java b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/valid/impl/type/ValidShapeRelation.java index 66e16f7f..adc6c7d3 100644 --- a/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/valid/impl/type/ValidShapeRelation.java +++ b/com.actionsoft.apps.coe.pal.batch/src/com/actionsoft/apps/coe/pal/batch/web/create/shape/valid/impl/type/ValidShapeRelation.java @@ -1,14 +1,11 @@ package com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.impl.type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import com.actionsoft.apps.AppsConst; import com.actionsoft.apps.coe.pal.batch.util.BatchUtil; +import com.actionsoft.apps.coe.pal.batch.web.create.process.ProcessConst; +import com.actionsoft.apps.coe.pal.batch.web.create.process.valid.ValidCell; import com.actionsoft.apps.coe.pal.batch.web.create.shape.ShapeConst; import com.actionsoft.apps.coe.pal.batch.web.create.shape.valid.ValidShapeCell; import com.actionsoft.apps.coe.pal.constant.CoEConstant; @@ -22,9 +19,13 @@ import com.actionsoft.i18n.I18nRes; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +/** + * 校验关联PAL模型和形状类型 + * @author sunlh + * + */ public class ValidShapeRelation implements ValidShapeCell { - private String getCategoryId(String categoryName) { Map result = new HashMap<>(); String [] methodArray = PALMethodCache.getPALMethodList(true).toArray(new String[0]); @@ -36,7 +37,7 @@ public class ValidShapeRelation implements ValidShapeCell { } return null; } - + @Override public Object validTableCell(Object param) { JSONObject paramObj = JSONObject.parseObject(param.toString()); @@ -74,81 +75,43 @@ public class ValidShapeRelation implements ValidShapeCell { isOk = false; msg = "单选属性不支持多个值"; } else { - for (String path : valueSet) { - String [] pathArr = path.split("/"); - boolean flag = true; - List tmpList = new ArrayList(); - for (int j = 0; j < pathArr.length; j++) { - if (UtilString.isEmpty(pathArr[j])) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - if (j == 0) {// 寻找流程大类是否存在 - if (!pathArr[j].equals(I18nRes.findValue(CoEConstant.APP_ID, category))) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList.add(category); - } else { - // 获取子节点 - List tmpList2 = new ArrayList(); - for (String pid : tmpList) { - List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(pathArr[j])) { - if (j == pathArr.length - 1) { - if ("default".equals(model.getMethodId())) { - isOk = false; - msg = "路径[" + path + "]末级流程不允许是文件夹"; - flag = false; - break; - } else if (!model.getMethodId().contains(method)) { - isOk = false; - msg = "路径[" + path + "]末级流程不符合属性范围要求"; - } else { - tmpList2.add(model.getId()); - } - } else { - tmpList2.add(model.getId()); - } - } - } - if (!flag) { - break; - } - } - if (flag && tmpList2.size() == 0) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList = tmpList2; + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + Map map = new HashMap<>(); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (model.isUse()) { + map.put(model.getId(), model.getName().trim()); + } + } + for (String name : valueSet) { + List ids = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (name.equals(entry.getValue())) { + ids.add(entry.getKey()); } } - if (flag) { - if (tmpList.size() == 0) { + if (ids.size() == 0) { + isOk = false; + msg = "[" + name + "]不存在"; + break; + } if (ids.size() > 1) { + isOk = false; + msg = "[" + name + "]出现多个匹配"; + break; + } else { + PALRepositoryModel model = PALRepositoryCache.getCache().get(ids.get(0)); + if ("default".equals(model.getMethodId())) { isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不允许是文件夹"; break; - } else if (tmpList.size() > 1) { + } else if (!model.getMethodId().contains(method)) { isOk = false; - msg = "路径[" + path + "]存在多个,无法匹配"; - break; - } else if (tmpList.get(0).length() < 36) { - isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不符合属性范围要求"; break; } else { isOk = true; - repositoryIds.add(tmpList.get(0)); + repositoryIds.add(model.getId()); } - } else { - break; } } } @@ -165,7 +128,7 @@ public class ValidShapeRelation implements ValidShapeCell { } } attr.put("relations", result); - } else {// 关联的是形状 + } else if ("shape".equals(type)) {// 关联的是形状 Set fileShapeIds = new HashSet<>(); String [] valueArr = value.split(","); // 过滤掉空值 @@ -179,113 +142,75 @@ public class ValidShapeRelation implements ValidShapeCell { isOk = false; msg = "单选属性不支持多个值"; } else { - for (String path : valueSet) { - String [] pathArr = path.split("/"); - boolean flag = true; - List tmpList = new ArrayList(); - for (int j = 0; j < pathArr.length; j++) { - if (UtilString.isEmpty(pathArr[j])) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - if (j == 0) {// 寻找流程大类是否存在 - if (!pathArr[j].equals(I18nRes.findValue(CoEConstant.APP_ID, category))) { - isOk = false; - msg = "大类路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList.add(category); - } else { - // 获取子节点 - List tmpList2 = new ArrayList(); - for (String pid : tmpList) { - List list = PALRepositoryCache.getAllSubModelsByPid(wsId, pid); - String repositoryName = null; - String shapeName = null; - if (j == pathArr.length - 1) { - // 拆分名称为名称+节点名称 - String [] namePath = pathArr[j].split(":"); - if (namePath.length == 2 && !UtilString.isEmpty(namePath[0]) && !UtilString.isEmpty(namePath[1])) { - repositoryName = namePath[0]; - shapeName = namePath[1]; - } else { - isOk = false; - msg = "路径[" + path + "]末级流程与节点信息错误"; - flag = false; - break; - } - } - if (j == pathArr.length - 1) {// 最后一个层级 - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(repositoryName)) { - if ("default".equals(model.getMethodId())) { - isOk = false; - msg = "路径[" + path + "]末级流程不允许是文件夹"; - flag = false; - break; - } else if (!model.getMethodId().contains(method)) { - isOk = false; - msg = "路径[" + path + "]末级流程不符合属性范围要求"; - } else { - // 获取节点数据 - String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId()); - List shapes = ShapeUtil.getShapeJsonToJsonObject(definition); - for (JSONObject shape : shapes) { - if (shapeName.equals(shape.getString("text"))) { - // 获取匹配的节点数据 - tmpList2.add(model.getId() + ":" + shape.getString("id") + ":" + shape.getString("text")); - } - } - } - } - } - } else { - for (PALRepositoryModel model : list) { - if (model.isUse() && model.getName().equals(pathArr[j])) { - tmpList2.add(model.getId()); - } - } - } - if (!flag) { - break; - } - } - if (flag && tmpList2.size() == 0) { - isOk = false; - msg = "路径[" + path + "]不存在"; - flag = false; - break; - } - tmpList = tmpList2; + Iterator iterator = PALRepositoryCache.getByWsId(wsId); + Map map = new HashMap<>(); + while (iterator.hasNext()) { + PALRepositoryModel model = iterator.next(); + if (model.isUse()) { + map.put(model.getId(), model.getName().trim()); + } + } + for (String nameArr : valueSet) { + // 拆分名称为名称+节点名称 + String name = null; + String shapeName = null; + String [] namePath = nameArr.split(":"); + if (namePath.length == 2 && !UtilString.isEmpty(namePath[0]) && !UtilString.isEmpty(namePath[1])) { + name = namePath[0]; + shapeName = namePath[1]; + } else { + isOk = false; + msg = "[" + nameArr + "]末级模型与节点信息错误"; + break; + } + List ids = new ArrayList<>(); + for (Map.Entry entry : map.entrySet()) { + if (name.equals(entry.getValue())) { + ids.add(entry.getKey()); } } - if (flag) { - if (tmpList.size() == 0) { + if (ids.size() == 0) { + isOk = false; + msg = "[" + name + "]不存在"; + break; + } if (ids.size() > 1) { + isOk = false; + msg = "[" + name + "]出现多个匹配"; + break; + } else { + PALRepositoryModel model = PALRepositoryCache.getCache().get(ids.get(0)); + if ("default".equals(model.getMethodId())) { isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不允许是文件夹"; break; - } else if (tmpList.size() > 1) { + } else if (!model.getMethodId().contains(method)) { isOk = false; - msg = "路径[" + path + "]存在多个,无法匹配"; - break; - } else if (tmpList.get(0).length() < 36) { - isOk = false; - msg = "路径[" + path + "]不存在"; + msg = "[" + name + "]不符合属性范围要求"; break; } else { + String result = null; + // 获取节点数据 + String definition = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId()); + List shapes = ShapeUtil.getShapeJsonToJsonObject(definition); + for (JSONObject shape : shapes) { + if (shapeName.equals(shape.getString("text"))) { + // 获取匹配的节点数据 + result = model.getId() + ":" + shape.getString("id") + ":" + shape.getString("text"); + } + } + if (result == null) { + isOk = false; + msg = "[" + shapeName + "]不存在"; + break; + } isOk = true; - fileShapeIds.add(tmpList.get(0)); + fileShapeIds.add(result); } - } else { - break; } } } - + JSONArray shapes = new JSONArray(); for (String fileShape : fileShapeIds) { String [] fileArr = fileShape.split(":"); @@ -296,6 +221,8 @@ public class ValidShapeRelation implements ValidShapeCell { shapes.add(object); } attr.put("relations", shapes); + } else { + msg = "不支持形状和模型同时选择的类型"; } JSONObject result = new JSONObject(); result.put("name", title);