aris导入流程时输出属性形状未删除、属性未赋值处理
This commit is contained in:
parent
fc292b31e5
commit
f19ea3233c
Binary file not shown.
@ -276,10 +276,8 @@ public class DataMigrationWeb extends ActionWeb {
|
||||
// 创建形状和连线
|
||||
JSONObject newElements = createShapeElement(wsId, idRelationMap, palModel, arisModel, modelObjOccMap, objDefMap, objOccMap, cxnOccMap, palShapeIdRelationArisOccIdMap);
|
||||
|
||||
if (newElements == null) continue;
|
||||
|
||||
// 处理输入输出活动属性
|
||||
this.handleShapeInputOutAttr(wsId, idRelationMap, newElements, arisModel, modelObjOccMap, objDefMap);
|
||||
this.handleShapeInputOutAttr(palModel, newElements);
|
||||
|
||||
// 处理角色属性与流程相应的活动节点关联
|
||||
this.handleProcessAttrRoleRelation(wsId, palModel.getId(), arisFunIdRelationPalRoleMap, palShapeIdRelationArisOccIdMap, newElements, arisModel, modelObjOccMap, objDefMap, roleMdoelId, palRoleIdRelationNameMap);
|
||||
@ -874,155 +872,161 @@ public class DataMigrationWeb extends ActionWeb {
|
||||
}
|
||||
|
||||
/**
|
||||
* 在现有输出的图形结构上转化输入 输出活动属性
|
||||
*
|
||||
* @param wsId
|
||||
* @param idRelationMap
|
||||
* @param elements
|
||||
* @param arisModel
|
||||
* @param modelObjOccMap
|
||||
* @param objDefMap
|
||||
* 在现有输出的图形结构上转化输入 输出活动属性,并将图上输入输出及连线删除
|
||||
*/
|
||||
private void handleShapeInputOutAttr(String wsId, Map<String, String> idRelationMap, JSONObject elements, ModelModel arisModel, Map<String, List<ObjOccModel>> modelObjOccMap,
|
||||
Map<String, ObjDefModel> objDefMap) {
|
||||
// 获取ARIS图形定义与PAL图形定义关系
|
||||
Map<String, ObjDefMappingModel> objDefMappingMap = ModelMappingAPIManager.getInstance().getObjDefMappingMap();
|
||||
ObjDefMappingModel objDefMappingModel = objDefMappingMap.get("OT_INFO_CARR-ST_DOC");
|
||||
// 获取当前ARIS模型下所有的图形信息
|
||||
List<ObjOccModel> objOccModels = modelObjOccMap.get(arisModel.getId());
|
||||
private void handleShapeInputOutAttr(PALRepositoryModel palModel, JSONObject elements) {
|
||||
// 存放待删除图形的KEY
|
||||
List<String> removeKey = new ArrayList<>();
|
||||
for (ObjOccModel objOccModel : objOccModels) {
|
||||
ObjDefModel objDefModel = objDefMap.get(objOccModel.getDefId());// 形状定义
|
||||
// 根据ARIS图形定义信息判断当前模型下的所有形状里是否有输入 输出形状
|
||||
if (objDefModel.getTypeNum().equals(objDefMappingModel.getTypeNum()) && objDefModel.getSymbolNum().equals(objDefMappingModel.getSymbolNum())) {
|
||||
// 如果有输入输出形状 取出关联的PAL模型ID
|
||||
String shapeId = idRelationMap.get(objOccModel.getId());
|
||||
JSONObject inputOrOutObj = elements.getJSONObject(shapeId);
|
||||
// 遍历所有的PAL形状 根据连线走向判断是输出还是输入
|
||||
|
||||
Map<String, Set<String>> nextShapeMap = new HashMap<>();// 记录当前形状的下一个(多个)形状
|
||||
Map<String, Set<String>> prevShapeMap = new HashMap<>();// 记录当前形状的上一个(多个)形状
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shapeObj = elements.getJSONObject(key);
|
||||
if ("linker".equals(shapeObj.getString("name"))) {
|
||||
List<PALMethodAttributeModel> attributeModels = CoeDesignerShapeAPIManager.getInstance()
|
||||
.getValidAttributeModels(wsId, objDefMappingModel.getShapeMethod(), "process", objDefMappingModel.getShapeMethod());
|
||||
// 输入
|
||||
String shapeId = shapeObj.getString("id");
|
||||
// 查找入线
|
||||
String fromId = shapeObj.getJSONObject("from").getString("id");
|
||||
String toId = shapeObj.getJSONObject("to").getString("id");
|
||||
// 记录from->to Map
|
||||
if (!nextShapeMap.containsKey(fromId)) {
|
||||
nextShapeMap.put(fromId, new HashSet<>());
|
||||
}
|
||||
nextShapeMap.get(fromId).add(toId);
|
||||
|
||||
// System.out.println("所有图形model");
|
||||
if (shapeObj.getJSONObject("from").getString("id").equals(shapeId)) {
|
||||
// 作为输入属性
|
||||
System.out.println("有输入属性");
|
||||
attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_INPUT.equals(item.getKey())).collect(Collectors.toList());
|
||||
PALMethodAttributeModel attributeModel = attributeModels.get(0);
|
||||
JSONObject inputObj = new JSONObject();
|
||||
inputObj.put("value", inputOrOutObj.getString("text"));
|
||||
inputObj.put("key", attributeModel.getKey());
|
||||
inputObj.put("isRequired", attributeModel.getIsRequired());
|
||||
inputObj.put("ref", attributeModel.getRef());
|
||||
inputObj.put("readonly", attributeModel.getReadonly());
|
||||
inputObj.put("scope", attributeModel.getScope());
|
||||
inputObj.put("name", attributeModel.getTitle());
|
||||
inputObj.put("id", attributeModel.getKey());
|
||||
inputObj.put("textarea", attributeModel.getType());
|
||||
inputObj.put("groupPath", attributeModel.getGroupPath());
|
||||
inputObj.put("desc", attributeModel.getDesc());
|
||||
// 将转化后的信息放到相应位置
|
||||
String toShapeId = shapeObj.getJSONObject("to").getString("id");
|
||||
JSONArray dataAttributes = elements.getJSONObject(toShapeId).getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
JSONArray tempJSONArr = attributesJsonArray.stream()
|
||||
.filter(item -> ((JSONObject) item).getString("key").equals(attributeModel.getKey()))
|
||||
.collect(Collectors.toCollection(JSONArray::new));
|
||||
if (tempJSONArr.size() > 0) {
|
||||
for (Object o : attributesJsonArray) {
|
||||
if (attributeModel.getKey().equals(((JSONObject) o).getString("key"))) {
|
||||
String tempValue = new StringBuffer(((JSONObject) o).getString("value"))
|
||||
.append(",").append(inputOrOutObj.getString("text")).toString();
|
||||
((JSONObject) o).put("value", tempValue);
|
||||
if (!prevShapeMap.containsKey(toId)) {
|
||||
prevShapeMap.put(toId, new HashSet<>());
|
||||
}
|
||||
prevShapeMap.get(toId).add(fromId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
obj.getJSONArray("attributesJsonArray").add(inputObj);
|
||||
|
||||
Map<String, Set<String>> shapeInputMap = new HashMap<>();// 记录形状的所有输出
|
||||
Map<String, Set<String>> shapeOutMap = new HashMap<>();// 记录形状的所有输入
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shapeObj = elements.getJSONObject(key);
|
||||
if (!"linker".equals(shapeObj.getString("name"))) {
|
||||
// 输入
|
||||
String shapeId = shapeObj.getString("id");
|
||||
// 查找入线(输入)
|
||||
if (prevShapeMap.containsKey(shapeId)) {
|
||||
for (Map.Entry<String, Set<String>> entry : prevShapeMap.entrySet()) {
|
||||
if (key.equals(entry.getKey())) {
|
||||
Set<String> prevShapeIds = entry.getValue();
|
||||
for (String prevShapeId : prevShapeIds) {
|
||||
JSONObject prevShape = elements.getJSONObject(prevShapeId);
|
||||
if ("document".equals(prevShape.getString("name"))) {
|
||||
if (!shapeInputMap.containsKey(shapeId)) {
|
||||
shapeInputMap.put(shapeId, new HashSet<>());
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
obj.put("attributesJsonArray", new JSONArray());
|
||||
obj.getJSONArray("attributesJsonArray").add(inputObj);
|
||||
break;
|
||||
shapeInputMap.get(shapeId).add(prevShape.getString("text"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除图形与连线
|
||||
}
|
||||
}
|
||||
// 查找出线
|
||||
if (nextShapeMap.containsKey(shapeId)) {
|
||||
for (Map.Entry<String, Set<String>> entry : nextShapeMap.entrySet()) {
|
||||
if (key.equals(entry.getKey())) {
|
||||
Set<String> nextShapeIds = entry.getValue();
|
||||
for (String nextShapeId : nextShapeIds) {
|
||||
JSONObject nextShape = elements.getJSONObject(nextShapeId);
|
||||
if ("document".equals(nextShape.getString("name"))) {
|
||||
if (!shapeOutMap.containsKey(shapeId)) {
|
||||
shapeOutMap.put(shapeId, new HashSet<>());
|
||||
}
|
||||
shapeOutMap.get(shapeId).add(nextShape.getString("text"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shapeObj = elements.getJSONObject(key);
|
||||
if ("linker".equals(shapeObj.getString("name"))) {
|
||||
JSONObject from = elements.getJSONObject(shapeObj.getJSONObject("from").getString("id"));
|
||||
if ("document".equals(from.getString("name"))) {
|
||||
removeKey.add(key);
|
||||
removeKey.add(shapeId);
|
||||
printMsg("输入属性【" + inputOrOutObj.getString("text") + "】处理完毕");
|
||||
// }else if (shapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
|
||||
// by shang --处理输出属性,不是else
|
||||
removeKey.add(from.getString("id"));
|
||||
}
|
||||
if (shapeObj.getJSONObject("to").getString("id").equals(shapeId)) {
|
||||
// 作为输出属性
|
||||
System.out.println("有输出属性");
|
||||
// 输出属性,暂时写死为out,和常量没对应上,原因待解决
|
||||
attributeModels = attributeModels.stream().filter(item -> Constant.METHOD_OUTPUT.equals(item.getKey())).collect(Collectors.toList());
|
||||
// attributeModels = attributeModels.stream().filter(item -> "out".equals(item.getKey())).collect(Collectors.toList());
|
||||
if (attributeModels.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
PALMethodAttributeModel attributeModel = attributeModels.get(0);
|
||||
JSONObject outObj = new JSONObject();
|
||||
outObj.put("value", inputOrOutObj.getString("text"));
|
||||
outObj.put("key", attributeModel.getKey());
|
||||
outObj.put("isRequired", attributeModel.getIsRequired());
|
||||
outObj.put("ref", attributeModel.getRef());
|
||||
outObj.put("readonly", attributeModel.getReadonly());
|
||||
outObj.put("scope", attributeModel.getScope());
|
||||
outObj.put("name", attributeModel.getTitle());
|
||||
outObj.put("id", attributeModel.getKey());
|
||||
outObj.put("textarea", attributeModel.getType());
|
||||
outObj.put("groupPath", attributeModel.getGroupPath());
|
||||
outObj.put("desc", attributeModel.getDesc());
|
||||
// 将转化后的信息放到相应位置
|
||||
String fromShapeId = shapeObj.getJSONObject("from").getString("id");
|
||||
JSONArray dataAttributes = elements.getJSONObject(fromShapeId).getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
JSONArray tempJSONArr = attributesJsonArray.stream()
|
||||
.filter(item -> ((JSONObject) item).getString("key").equals(attributeModel.getKey()))
|
||||
.collect(Collectors.toCollection(JSONArray::new));
|
||||
if (tempJSONArr.size() > 0) {
|
||||
for (Object o : attributesJsonArray) {
|
||||
if (attributeModel.getKey().equals(((JSONObject) o).getString("key"))) {
|
||||
String tempValue = new StringBuffer(((JSONObject) o).getString("value"))
|
||||
.append(",").append(inputOrOutObj.getString("text")).toString();
|
||||
((JSONObject) o).put("value", tempValue);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
obj.getJSONArray("attributesJsonArray").add(outObj);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
obj.put("attributesJsonArray", new JSONArray());
|
||||
obj.getJSONArray("attributesJsonArray").add(outObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除图形与连线
|
||||
JSONObject to = elements.getJSONObject(shapeObj.getJSONObject("to").getString("id"));
|
||||
if ("document".equals(to.getString("name"))) {
|
||||
removeKey.add(key);
|
||||
removeKey.add(shapeId);
|
||||
printMsg("输出属性【" + inputOrOutObj.getString("text") + "】处理完毕");
|
||||
}
|
||||
}
|
||||
removeKey.add(to.getString("id"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除画布上的输入输出和其连线
|
||||
removeKey.stream().forEach(key -> elements.remove(key));
|
||||
|
||||
Map<String, JSONObject> attrMap = new HashMap<>();
|
||||
JSONObject attrs1 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node");
|
||||
attrMap.put("method_service_node", attrs1);
|
||||
JSONObject attrs2 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_service_node4");
|
||||
attrMap.put("method_service_node4", attrs2);
|
||||
JSONObject attrs3 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node");
|
||||
attrMap.put("method_approval_node", attrs3);
|
||||
JSONObject attrs4 = ShapeUtil.getProcessUseShapeMethodAttrByShapeName(palModel.getWsId(), palModel.getMethodId(), palModel.getMethodId(), "method_approval_node3");
|
||||
attrMap.put("method_approval_node3", attrs4);
|
||||
|
||||
for (String key : elements.keySet()) {
|
||||
JSONObject shapeObj = elements.getJSONObject(key);
|
||||
if (!"linker".equals(shapeObj.getString("name"))) {
|
||||
if (attrMap.containsKey(shapeObj.getString("name"))) {
|
||||
JSONObject attrs = attrMap.get(shapeObj.getString("name"));
|
||||
if (shapeInputMap.containsKey(key)) {// 有输入属性
|
||||
// 输入属性
|
||||
if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_INPUT)) {
|
||||
JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_INPUT).toString());
|
||||
List<String> contentList = new ArrayList<>(shapeInputMap.get(key));
|
||||
Collections.sort(contentList);
|
||||
attrObj.put("value", StringUtils.join(contentList, ","));
|
||||
JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
attributesJsonArray.add(attrObj);
|
||||
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输入属性内容" + attrObj.getString("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输入属性");
|
||||
}
|
||||
}
|
||||
if (shapeOutMap.containsKey(key)) {// 有输出属性
|
||||
// 输出属性
|
||||
if (attrs != null && attrs.size() > 0 && attrs.containsKey(Constant.METHOD_OUTPUT)) {
|
||||
JSONObject attrObj = JSONObject.parseObject(attrs.getJSONObject(Constant.METHOD_OUTPUT).toString());
|
||||
List<String> contentList = new ArrayList<>(shapeOutMap.get(key));
|
||||
Collections.sort(contentList);
|
||||
attrObj.put("value", StringUtils.join(contentList, ","));
|
||||
JSONArray dataAttributes = shapeObj.getJSONArray("dataAttributes");
|
||||
if (!dataAttributes.isEmpty() && dataAttributes.size() > 0) {
|
||||
for (Object attribute : dataAttributes) {
|
||||
JSONObject obj = (JSONObject) attribute;
|
||||
if (obj.containsKey("attributesJsonArray")) {
|
||||
JSONArray attributesJsonArray = obj.getJSONArray("attributesJsonArray");
|
||||
attributesJsonArray.add(attrObj);
|
||||
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "输出属性内容" + attrObj.getString("value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
printMsg("流程" + palModel.getName() + "的节点" + shapeObj.getString("text") + "没有配置输出属性");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user