模型转换应用阶段提交

This commit is contained in:
qinoy 2022-09-28 09:51:41 +08:00
parent 226d5937dc
commit 881a988d76
8 changed files with 516 additions and 3 deletions

View File

@ -0,0 +1,29 @@
package com.actionsoft.apps.coe.pal.modelconvert.cache;
import java.util.HashMap;
import java.util.Map;
public class ConvertShapeIdMapping {
private ConvertShapeIdMapping(){}
private static ConvertShapeIdMapping convertShapeIdMapping = new ConvertShapeIdMapping();
// 存储被转换文件图形ID与转换后的文件图形ID的映射关系
private static Map<String,String> shapeIdMapping = new HashMap<>();
public static ConvertShapeIdMapping getInstance(){
return convertShapeIdMapping;
}
public void load(String sourceShapeId,String targetShapeId){
shapeIdMapping.put(sourceShapeId,targetShapeId);
}
public void clear(){
shapeIdMapping.clear();
}
public String getTargetShapeId(String sourceShapeId){
return shapeIdMapping.get(sourceShapeId);
}
}

View File

@ -0,0 +1,90 @@
package com.actionsoft.apps.coe.pal.modelconvert.model;
import com.actionsoft.bpms.commons.mvc.model.ModelBean;
public class RelationAttributeModel extends ModelBean {
private String fileId; // 当前资产库文件Id
private String shapeId; // 当前图形Id
private String shapeText; // 当前图形文本
private String attrId; // 建模属性的标识
private String relationFileId; // 关联文件Id
private String relationShapeId; // 关联图形的Id
private String relationShapeText; // 关联类型type为file时 该字段存储文件名 关联类型type为shape时 该字段存储图形的文本
private String groupPath;
public RelationAttributeModel(String fileId, String shapeId, String shapeText, String attrId, String relationFileId, String relationShapeId, String relationShapeText, String groupPath) {
this.fileId = fileId;
this.shapeId = shapeId;
this.shapeText = shapeText;
this.attrId = attrId;
this.relationFileId = relationFileId;
this.relationShapeId = relationShapeId;
this.relationShapeText = relationShapeText;
this.groupPath = groupPath;
}
public String getFileId() {
return fileId;
}
public void setFileId(String fileId) {
this.fileId = fileId;
}
public String getShapeId() {
return shapeId;
}
public void setShapeId(String shapeId) {
this.shapeId = shapeId;
}
public String getShapeText() {
return shapeText;
}
public void setShapeText(String shapeText) {
this.shapeText = shapeText;
}
public String getAttrId() {
return attrId;
}
public void setAttrId(String attrId) {
this.attrId = attrId;
}
public String getRelationFileId() {
return relationFileId;
}
public void setRelationFileId(String relationFileId) {
this.relationFileId = relationFileId;
}
public String getRelationShapeId() {
return relationShapeId;
}
public void setRelationShapeId(String relationShapeId) {
this.relationShapeId = relationShapeId;
}
public String getRelationShapeText() {
return relationShapeText;
}
public void setRelationShapeText(String relationShapeText) {
this.relationShapeText = relationShapeText;
}
public String getGroupPath() {
return groupPath;
}
public void setGroupPath(String groupPath) {
this.groupPath = groupPath;
}
}

View File

@ -0,0 +1,34 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl.AwsOrgTypeAttrHandle;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl.RelationTypeAttrHandle;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl.TextTypeAttrHandle;
import java.util.HashMap;
import java.util.Map;
public class DataAttributeContext {
private DataAttributeContext(){}
private static DataAttributeContext dataAttributeContext = new DataAttributeContext();
private static Map<String, DataAttributeStrategy> map = new HashMap<>();
static {
map.put("number",new TextTypeAttrHandle());
map.put("string",new TextTypeAttrHandle());
map.put("textarea",new TextTypeAttrHandle());
map.put("link",new TextTypeAttrHandle());
map.put("DateTimePicker",new TextTypeAttrHandle());
map.put("table",new TextTypeAttrHandle());
map.put("relation",new RelationTypeAttrHandle());
map.put("awsorg",new AwsOrgTypeAttrHandle());
}
public static DataAttributeContext getInstance(){
return dataAttributeContext;
}
public DataAttributeStrategy dataAttributeStrategy(String type){
return map.get(type);
}
}

View File

@ -0,0 +1,12 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute;
import java.util.Map;
public interface DataAttributeStrategy {
// 文件属性处理
void fileAttrHandle(Map<String,Object> param);
// 图形属性处理
void shapeAttrHandle(Map<String,Object> param);
}

View File

@ -0,0 +1,77 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class AwsOrgTypeAttrHandle implements DataAttributeStrategy {
@Override
public void fileAttrHandle(Map<String, Object> param) {
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String attrId = (String) param.get("attrId");
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> sourceRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
// 关联类型的文件属性 关联表中 shapeId shapeText 字段是空值
sourceRelationModelList = sourceRelationModelList.stream()
.filter(model -> UtilString.isEmpty(model.getShapeId()) && UtilString.isEmpty(model.getShapeText()))
.filter(model -> attrId.equals(model.getAttrId()))
.filter(model -> "00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId()))
.collect(Collectors.toList());
List<DesignerShapeRelationModel> result = new ArrayList<>();
for (DesignerShapeRelationModel relationModel : sourceRelationModelList) {
DesignerShapeRelationModel targetRelationModel = new DesignerShapeRelationModel();
targetRelationModel.setId(UUIDGener.getUUID());
targetRelationModel.setFileId(targetRepositoryId);
targetRelationModel.setShapeId(relationModel.getShapeId());
targetRelationModel.setShapeText(relationModel.getShapeText());
targetRelationModel.setAttrId(relationModel.getAttrId());
targetRelationModel.setRelationFileId(relationModel.getRelationFileId());
targetRelationModel.setRelationShapeId(relationModel.getRelationShapeId());
targetRelationModel.setRelationShapeText(relationModel.getRelationShapeText());
result.add(targetRelationModel);
}
shapeRelationDao.barchInsert(result);
}
@Override
public void shapeAttrHandle(Map<String, Object> param) {
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String attrId = (String) param.get("attrId");
// 2. _shape_rlat 表做处理
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> shapeRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
shapeRelationModelList = shapeRelationModelList.stream()
.filter(model -> attrId.equals(model.getAttrId()))
.filter(model -> UtilString.isNotEmpty(model.getShapeId()) && UtilString.isNotEmpty(model.getShapeText()))
.filter(model -> "00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && "00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId()))
.collect(Collectors.toList());
List<DesignerShapeRelationModel> result = new ArrayList<>();
for (DesignerShapeRelationModel relationModel : shapeRelationModelList) {
if (UtilString.isEmpty(ConvertShapeIdMapping.getInstance().getTargetShapeId(relationModel.getShapeId()))) { // 如果转换前为 事件 图形 直接跳过
continue;
}
relationModel.setId(UUIDGener.getUUID());
relationModel.setFileId(targetRepositoryId);
relationModel.setShapeId(ConvertShapeIdMapping.getInstance().getTargetShapeId(relationModel.getShapeId()));
relationModel.setShapeText(relationModel.getShapeText());
relationModel.setAttrId(relationModel.getAttrId());
relationModel.setRelationFileId(relationModel.getRelationFileId());
relationModel.setRelationShapeId(relationModel.getRelationShapeId());
relationModel.setRelationShapeText(relationModel.getRelationShapeText());
result.add(relationModel);
}
shapeRelationDao.barchInsert(result);
}
}

View File

@ -0,0 +1,78 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.bpms.util.UUIDGener;
import com.actionsoft.bpms.util.UtilString;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class RelationTypeAttrHandle implements DataAttributeStrategy {
@Override
public void fileAttrHandle(Map<String, Object> param) {
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String attrId = (String) param.get("attrId");
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> sourceRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
// 关联类型的文件属性 关联表中 shapeId shapeText 字段是空值
sourceRelationModelList = sourceRelationModelList.stream()
.filter(model -> UtilString.isEmpty(model.getShapeId()) && UtilString.isEmpty(model.getShapeText()))
.filter(model -> attrId.equals(model.getAttrId()))
.filter(model -> !"00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && !"00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId()))
.collect(Collectors.toList());
List<DesignerShapeRelationModel> result = new ArrayList<>();
for (DesignerShapeRelationModel relationModel : sourceRelationModelList) {
DesignerShapeRelationModel targetRelationModel = new DesignerShapeRelationModel();
targetRelationModel.setId(UUIDGener.getUUID());
targetRelationModel.setFileId(targetRepositoryId);
targetRelationModel.setShapeId(relationModel.getShapeId());
targetRelationModel.setShapeText(relationModel.getShapeText());
targetRelationModel.setAttrId(relationModel.getAttrId());
targetRelationModel.setRelationFileId(relationModel.getRelationFileId());
targetRelationModel.setRelationShapeId(relationModel.getRelationShapeId());
targetRelationModel.setRelationShapeText(relationModel.getRelationShapeText());
result.add(targetRelationModel);
}
shapeRelationDao.barchInsert(result);
}
@Override
public void shapeAttrHandle(Map<String, Object> param) {
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String attrId = (String) param.get("attrId");
// 1. definition 做处理
// 2. _shape_rlat 表做处理
DesignerShapeRelationDao shapeRelationDao = new DesignerShapeRelationDao();
List<DesignerShapeRelationModel> shapeRelationModelList = shapeRelationDao.getModelListByFileId(sourceRepositoryId);
shapeRelationModelList = shapeRelationModelList.stream()
.filter(model -> attrId.equals(model.getAttrId()))
.filter(model -> UtilString.isNotEmpty(model.getShapeId()) && UtilString.isNotEmpty(model.getShapeText()))
.filter(model -> !"00000000-0000-0000-0000-000000000000".equals(model.getRelationFileId()) && !"00000000-0000-0000-0000-000000000000".equals(model.getRelationShapeId()))
.collect(Collectors.toList());
List<DesignerShapeRelationModel> result = new ArrayList<>();
for (DesignerShapeRelationModel relationModel : shapeRelationModelList) {
if (UtilString.isEmpty(ConvertShapeIdMapping.getInstance().getTargetShapeId(relationModel.getShapeId()))) { // 如果转换前为 事件 图形 直接跳过
continue;
}
relationModel.setId(UUIDGener.getUUID());
relationModel.setFileId(targetRepositoryId);
relationModel.setShapeId(ConvertShapeIdMapping.getInstance().getTargetShapeId(relationModel.getShapeId()));
relationModel.setShapeText(relationModel.getShapeText());
relationModel.setAttrId(relationModel.getAttrId());
relationModel.setRelationFileId(relationModel.getRelationFileId());
relationModel.setRelationShapeId(relationModel.getRelationShapeId());
relationModel.setRelationShapeText(relationModel.getRelationShapeText());
result.add(relationModel);
}
shapeRelationDao.barchInsert(result);
}
}

View File

@ -0,0 +1,128 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.impl;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepositoryPropertyDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel;
import com.actionsoft.bpms.util.UUIDGener;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 文本类型 包含 单行 多行文本 日期 链接 表格 数字等类型
* 文件属性以及图形属性的处理
*/
public class TextTypeAttrHandle implements DataAttributeStrategy {
@Override
public void fileAttrHandle(Map<String, Object> param) {
// 直接处理 _prop表
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String sourcePropertyId = (String) param.get("attrId");
PALRepositoryPropertyDao propertyDao = new PALRepositoryPropertyDao();
List<PALRepositoryPropertyModel> propertyList = propertyDao.getPropertysByPlid(sourceRepositoryId, sourcePropertyId);
List<PALRepositoryPropertyModel> result = new ArrayList<>();
for (PALRepositoryPropertyModel sourcePropertyModel : propertyList) {
PALRepositoryPropertyModel propertyModel = new PALRepositoryPropertyModel();
propertyModel.setId(UUIDGener.getUUID());
propertyModel.setPlId(targetRepositoryId);
propertyModel.setPropertyId(sourcePropertyModel.getPropertyId());
propertyModel.setPropertyName(sourcePropertyModel.getPropertyName());
propertyModel.setPropertyValue(sourcePropertyModel.getPropertyValue());
propertyModel.setOrderIndex(0);
result.add(propertyModel);
}
propertyDao.batchInsert(result);
}
@Override
public void shapeAttrHandle(Map<String, Object> param) {
// 直接处理 definition
String sourceRepositoryId = (String) param.get("sourceRepositoryId");
String targetRepositoryId = (String) param.get("targetRepositoryId");
String sourcePropertyId = (String) param.get("sourcePropertyId");
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(sourceRepositoryId, 0);
String definition = baseModel.getDefinition();
JSONObject defineJsonObj = JSONObject.parseObject(definition);
JSONObject sourceElements = defineJsonObj.getJSONObject("elements");
sourceElements.keySet().stream()
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("linker"))
.filter(key -> !sourceElements.getJSONObject(key).getString("name").equals("event")) // 事件的属性直接跳过了 因为转换后 事件图形变成连线了
.forEach(key -> {
// 当前被转换的节点图形
JSONObject sourceShape = sourceElements.getJSONObject(key);
if (sourceShape.containsKey("dataAttributes") && sourceShape.getJSONArray("dataAttributes") != null){
JSONArray dataAttributes = sourceShape.getJSONArray("dataAttributes");
if (dataAttributes.size() > 0){
for (int i = 0; i < dataAttributes.size(); i++) {
JSONObject item = dataAttributes.getJSONObject(i);
if (item.containsKey("attributesJsonArray")){
JSONArray attributesJsonArray = item.getJSONArray("attributesJsonArray");
for (int j = 0; j < attributesJsonArray.size(); j++) {
JSONObject object = attributesJsonArray.getJSONObject(j);
if (object == null) continue;
if (object.getString("id").equals(sourcePropertyId)){
// 将当前的属性存入到转换后的文件中
String targetDefinition = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0).getDefinition();
JSONObject targetDefineJsonObj = JSONObject.parseObject(targetDefinition);
JSONObject targetElements = targetDefineJsonObj.getJSONObject("elements");
JSONObject targetShape = targetElements.getJSONObject(ConvertShapeIdMapping.getInstance().getTargetShapeId(key));
if (targetShape.containsKey("dataAttributes") && targetShape.getJSONArray("dataAttributes") != null){
JSONArray targetDataAttributes = targetShape.getJSONArray("dataAttributes");
for (int k = 0; k < targetDataAttributes.size(); k++) {
JSONObject targetItem = targetDataAttributes.getJSONObject(k);
if (targetItem.containsKey("attributesJsonArray")){
JSONArray targetItemJSONArray = targetItem.getJSONArray("attributesJsonArray");
for (int l = 0; l < targetItemJSONArray.size(); l++) {
JSONObject targetObj = targetItemJSONArray.getJSONObject(l);
if (targetObj == null) continue;
if (targetObj.getString("id").equals(sourcePropertyId)) targetItemJSONArray.remove(l);
}
JSONObject tempObj = new JSONObject();
tempObj.put("isRequired",object.getBooleanValue("isRequired"));
tempObj.put("ref",object.getString("ref"));
tempObj.put("readonly",object.getBooleanValue("readonly"));
tempObj.put("scope",object.getString("scope"));
tempObj.put("name",object.getString("name"));
tempObj.put("icon",object.getString("icon"));
tempObj.put("id",object.getString("id"));
tempObj.put("type",object.getString("type"));
if ("table".equals(object.getString("type"))){
tempObj.put("value",object.getJSONObject("value"));
}else {
tempObj.put("value",object.getString("value"));
}
tempObj.put("groupPath",object.getString("groupPath"));
tempObj.put("key",object.getString("key"));
targetItemJSONArray.add(tempObj);
break;
}
}
}
targetElements.put(ConvertShapeIdMapping.getInstance().getTargetShapeId(key),targetShape);
targetDefineJsonObj.put("elements",targetElements);
BaseModel model = CoeDesignerAPIManager.getInstance().getDefinition(targetRepositoryId, 0);
if (model == null) {
model = CoeDesignerUtil.createModel(targetRepositoryId, 0);
}
model.setDefinition(JSONObject.toJSONString(targetDefineJsonObj));
CoeDesignerAPIManager.getInstance().storeDefinition(model);
break;
}
}
break;
}
}
}
}
});
}
}

View File

@ -1,17 +1,21 @@
package com.actionsoft.apps.coe.pal.modelconvert.strategy.impl;
import com.actionsoft.apps.coe.pal.modelconvert.cache.ConvertShapeIdMapping;
import com.actionsoft.apps.coe.pal.modelconvert.cache.RepositoryModelCache;
import com.actionsoft.apps.coe.pal.modelconvert.constant.LinkerDefConstant;
import com.actionsoft.apps.coe.pal.modelconvert.constant.ShapeConstant;
import com.actionsoft.apps.coe.pal.modelconvert.model.*;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.ModelConvertStrategy;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeContext;
import com.actionsoft.apps.coe.pal.modelconvert.strategy.attribute.DataAttributeStrategy;
import com.actionsoft.apps.coe.pal.modelconvert.util.ConvertUtil;
import com.actionsoft.apps.coe.pal.pal.repository.dao.CoeProcessLevelDaoFacotory;
import com.actionsoft.apps.coe.pal.pal.repository.dao.PALRepository;
import com.actionsoft.apps.coe.pal.pal.repository.dao.*;
import com.actionsoft.apps.coe.pal.pal.repository.designer.manage.CoeDesignerAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.model.BaseModel;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.CoeDesignerUtil;
import com.actionsoft.apps.coe.pal.pal.repository.designer.util.ShapeUtil;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryShapeAttributeModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.impl.PALRepositoryModelImpl;
import com.actionsoft.apps.coe.pal.pal.repository.util.CoeProcessLevelUtil;
import com.actionsoft.bpms.server.UserContext;
@ -64,6 +68,11 @@ public class EpcToFlowChart implements ModelConvertStrategy {
this.handleEPCToFlowChart(uc,repositoryId,newRepositoryId,targetMethod);
// 4.放入缓存同时放入历史记录表中
// 6处理转换后的flowchart模型的文件属性 节点属性 形状显示规则
this.handleDataAttribute(repositoryId,newRepositoryId,wsId,sourceMethod,targetMethod);
// 7. 处理附件
// 8. 小组权限问题
return null;
}
@ -89,6 +98,9 @@ public class EpcToFlowChart implements ModelConvertStrategy {
private void handleEPCToFlowChart(UserContext _uc,String repositoryId,String newRepositoryId,String targetMethodId){
// 每次转换前将存储的图形ID的映射关系清空
ConvertShapeIdMapping.getInstance().clear();
// 3根据当前EPC的define生成flowChart的define
BaseModel baseModel = CoeDesignerAPIManager.getInstance().getDefinition(repositoryId, 0);
String definition = baseModel.getDefinition();
@ -143,11 +155,19 @@ public class EpcToFlowChart implements ModelConvertStrategy {
elements.put(_id,decision);
// 记录待删除的逻辑图形的key值
toBeDeletes.add(key);
// 存储一下转换前与转换后图形ID的映射关系
ConvertShapeIdMapping.getInstance().load(key,_id);
}
if (!"linker".equals(shapeName)) {
element.put("category",targetMethodId);
double y = props.getDoubleValue("y");
if (y > maxShapeY[0]) maxShapeY[0] = y;
// 除判断条件中的图形外 其他图形的ID转换前与转换后是一致的 因为总体上是在转换前的 definition 上进行改造
if (!("and".equals(shapeName) || "or".equals(shapeName) || "xor".equals(shapeName) || "event".equals(shapeName))){
ConvertShapeIdMapping.getInstance().load(key,key);
}
}
});
// 处理事件节点
@ -399,7 +419,52 @@ public class EpcToFlowChart implements ModelConvertStrategy {
}
model.setDefinition(JSONObject.toJSONString(defineJsonObj));
CoeDesignerAPIManager.getInstance().storeDefinition(model);
// 6处理转换后的flowchart模型的文件属性 节点属性 形状显示规则
}
/**
* 处理文件属性 数据属性 形状显示规则
* EPC中有的属性配置 Flowchart没有的话 暂时不予导入
*/
private void handleDataAttribute(String sourceRepositoryId,String targetRepositoryId,String wsId,String sourceMethod,String targetMethod){
// 文件属性配置
PALRepositoryAttributeDao fileAttrDao = new PALRepositoryAttributeDao();
List<PALRepositoryAttributeModel> sourceFileAttrList = fileAttrDao.getFileAttribute(wsId, sourceMethod);
List<PALRepositoryAttributeModel> targetFileAttrList = fileAttrDao.getFileAttribute(wsId, targetMethod);
sourceFileAttrList.stream().forEach(sourceFileAttr -> {
boolean targetFileAttrIsExist = targetFileAttrList.stream()
.anyMatch(targetFileAttr -> sourceFileAttr.getAttrId().equals(targetFileAttr.getAttrId())
&& sourceFileAttr.getType().equals(targetFileAttr.getType()));
if (targetFileAttrIsExist){ // 如果转换后的文件的建模属性中也有该属性配置 则将被转换的属性值导入过来
// 文件属性值的处理
DataAttributeStrategy attributeStrategy = DataAttributeContext.getInstance().dataAttributeStrategy(sourceFileAttr.getType());
Map<String, Object> param = new HashMap<>();
param.put("sourceRepositoryId",sourceRepositoryId);
param.put("targetRepositoryId",targetRepositoryId);
param.put("attrId",sourceFileAttr.getAttrId());
attributeStrategy.fileAttrHandle(param);
}
});
// 图形属性配置
PALRepositoryShapeAttributeDao shapeAttrDao = new PALRepositoryShapeAttributeDao();
List<PALRepositoryShapeAttributeModel> sourceShapeAttrList = shapeAttrDao.getShapeAttribute(wsId, sourceMethod);
List<PALRepositoryShapeAttributeModel> targetShapeAttrList = shapeAttrDao.getShapeAttribute(wsId, targetMethod);
sourceShapeAttrList.stream().forEach(sourceShapeAttr -> {
boolean targetShapeAttrIsExist = targetShapeAttrList.stream()
.anyMatch(targetFileAttr -> sourceShapeAttr.getAttrId().equals(targetFileAttr.getAttrId())
&& sourceShapeAttr.getShapeName().equals(targetFileAttr.getShapeName()));
if (targetShapeAttrIsExist){ // 如果转换后的文件的图形建模属性中也有该属性配置 则将被转换的属性值导入过来
// 图形属性值的处理
DataAttributeStrategy attributeStrategy = DataAttributeContext.getInstance().dataAttributeStrategy(sourceShapeAttr.getType());
Map<String, Object> param = new HashMap<>();
param.put("sourceRepositoryId",sourceRepositoryId);
param.put("targetRepositoryId",targetRepositoryId);
param.put("attrId",sourceShapeAttr.getAttrId());
attributeStrategy.shapeAttrHandle(param);
}
});
// 形状显示规则
}
}