();
- int linkerCount = 0;
- int textCount = 0;
- for (String s : elementList) {
- JSONObject jsonObj = JSONObject.parseObject(s);
- if (jsonObj.containsKey("category")) {
- set.add(jsonObj.getString("category").replace("_", "."));
- if("standard".equals(jsonObj.getString("category"))) {
- textCount ++;
- }
- }
- if (jsonObj.containsKey("name") && "linker".equals(jsonObj.getString("name"))) {
- linkerCount ++;
- }
- }
- if ((linkerCount + textCount) == elementList.size()) {// 只有箭头或插入的文本或者只包含这两者
- return true;
- }
- if (set.size() == 0) {
- return false;
- }
- if (methodId.equals(pasteMethodId) || set.contains(methodId)) {
- return true;
- } else {
- String methodIds = PALMethodUtil.getCustom(methodId, subject);// 得到当前这个文件所关联的图形methodID
- if (!"".equals(methodIds)) {
- String strs[] = methodIds.split(",");
- for (String str : strs) {
- if (str.equals(pasteMethodId) || set.contains(str))
- return true;
- }
- return false;
- } else
- return false;
- }
- }
- }
+ return CoeProcessLevelDaoFacotory.createCoeProcessLevel().pasteToDatabse(list) + "";
+ }
- /**
- * 校验是否是在同一资产库下,不能跨资产库复制和粘贴可以跨文件和浏览器,只限同一用户
- *
- * @param pasteFileUUID 服务器上缓存中的文件ID
- * @param TargetFileUUID 粘贴的目标的源文件的ID
- * @return boolean
- */
- public boolean validationIsNotSameRepository(String pasteFileUUID, String TargetFileUUID) {
- PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(TargetFileUUID);
- String targetWsID = levelModel.getWsId();
- levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(pasteFileUUID);
- String pasteWsID = levelModel.getWsId();
- if (pasteWsID.equals(targetWsID)) {
- return true;
- }
- return false;
- }
+ /**
+ * 粘贴时关联关系的同步
+ *
+ * 些方法的作用如下:比如对A图形进行复制,现在粘贴时图形为A派生出来的称为B,此时的B中的属性还有关联关系应该和A是完全一样的
+ *
+ * @param list
+ */
+ private void pasteChangeRelationShapes(List list) {
+ DesignerRelationShapeCacheManager relationShapeCache = DesignerRelationShapeCacheManager.getInstance();
+ Map> userShapeMap = relationShapeCache.getShapemap();
+ Map shapeMap = userShapeMap.get(_uc.getUID());
- /**
- * 判断是不是同一用户
- *
- * @return
- */
- public boolean validationUser(Map> shapeMap, String userId) {
- if (!shapeMap.isEmpty()) {
- Set set = shapeMap.keySet();
- for (String u : set) {
- if (u.equals(userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中
- return true;
- }
- }
- }
- return false;
- }
+ String copyMessageJson = (String) shapeMap.get("shapeCopyContent");
+ JSONArray jsonArr = JSONArray.parseArray(copyMessageJson);
+ Map copyMessageMap = new HashMap();
+ for (int i = 0; i < jsonArr.size(); i++) {
+ JSONObject messageObject = JSONObject.parseObject(jsonArr.getString(i));
+ copyMessageMap.put(messageObject.getJSONArray("dataAttributes").getJSONObject(0).getString("shapeGroupId"), messageObject.getString("id"));
+ }
- /**
- * 将第一次复制的数据插入到数据库
- * @param elementList
- * @param subject
- * @return
- */
- public boolean copyToDatabase(List elementList, String subject) {
- List list = new ArrayList();
- for (int i = 0; i < elementList.size(); i++) {
- String messageJson = elementList.get(i);
- JSONObject jsonObj = JSONObject.parseObject(messageJson);
- // 对连线不作任何操作
- if ("linker".equals(jsonObj.getString("name"))) {
- continue;
- }
- Map map = ShapeUtil.getIsCopy(messageJson);
- String shapeGroupId = map.get("shapeGroupId");
- String isCopy = map.get("isCopy");
- if ("N".equals(isCopy)) {
- continue;
- }
- DesignerShapeCopyModel model = new DesignerShapeCopyModel();
- model.setShapeId(jsonObj.getString("id"));
- model.setShapeGroupId(shapeGroupId);
- model.setShapeMessage(elementList.get(i));
- model.setShapecategoryName(jsonObj.getString("category"));
- model.setShapeName(jsonObj.getString("name"));
- model.setisCopy(isCopy);
- model.setPalRepositoryId(subject);
- model.setShapeType(jsonObj.getString("title"));
- model.setIsDelete("N");
- list.add(model);
- }
- try {
- return CoeProcessLevelDaoFacotory.createCoeProcessLevel().createShape(list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
+ DesignerShapeRelationDao dao = new DesignerShapeRelationDao();
+ for (DesignerShapePasteModel model : list) {
+ String shapeGroupId = model.getShapeGroupId();
+ String copyShapeId = "";
+ if (copyMessageMap.containsKey(shapeGroupId)) {
+ copyShapeId = copyMessageMap.get(shapeGroupId);
+ }
+ List copyShapeRelationModel = dao.getModelListByShapeId(copyShapeId);
+ for (DesignerShapeRelationModel copyRelationModel : copyShapeRelationModel) {
+ DesignerShapeRelationModel relationModel = new DesignerShapeRelationModel();
+ relationModel.setId(UUIDGener.getUUID());
+ relationModel.setFileId(model.getPalRepositoryId());
+ relationModel.setShapeId(model.getShapeId());
+ relationModel.setShapeText(model.getShapeText());
+ relationModel.setAttrId(copyRelationModel.getAttrId());
+ relationModel.setRelationFileId(copyRelationModel.getRelationFileId());
+ relationModel.setRelationShapeId(copyRelationModel.getRelationShapeId());
+ relationModel.setRelationShapeText(copyRelationModel.getRelationShapeText());
+ dao.insert(relationModel);
+ }
+ }
+ }
- /**
- * 改变出现复制的图形的名称或属性,对出现复制的图形的名称和属性进行同步,如:
- * 对A图形进行复制派生出B那改变B或者A时两者的名称和属性应该是同步的并有相同的属性和名称
- * @param jsonObj
- * @param uuid
- */
- public void updateShapes(JSONObject jsonObj, String uuid) {
- // JSONObject jsonObj = JSONObject.fromObject(messages);
- JSONArray jsonArr1 = jsonObj.getJSONArray("updates");
- DesignerRelationShapeCacheManager event = DesignerRelationShapeCacheManager.getInstance();
- Map> map = event.getEventMap();
- // 只针对单个 图形进行操作
- if (jsonArr1.size() > 1) {
- event.setFlag(false);
- return;
- }
- JSONObject jsonObj2 = jsonArr1.getJSONObject(0);
- if (!jsonObj2.containsKey("anchors")) {
- event.setFlag(false);
- return;
- }
- String name = jsonObj2.getString("text");
- String id = jsonObj2.getString("id");
- if (map != null) {
- Set l = map.get(uuid);
- if (l != null) {
- // 如果名称或属性没有什么变化,只是改变改图形的位置、连线什么的, 则不会唤醒正在阻塞的http长连接的线程
- for (JSONObject jsonObject : l) {
- if (id.equals(jsonObject.getString("id")) && name.equals(jsonObject.getString("text")) && isTheSame(jsonObj2.getJSONArray("dataAttributes"), jsonObject.getJSONArray("dataAttributes"))) {
- event.setFlag(false);
- return;
- }
- }
- } else {
- // 否则唤醒正在等待的http长连接的线程
- event.setFlag(false);
- }
- }
- }
+ /**
+ * 判断当前这个文件是否可以粘贴被复制的图形,只有当当前的文件中存大更多图形并且已选择要粘贴的图形的类别时才能进行粘贴和解析,BPMN只能粘贴
+ * 在BPMN中,不能粘贴到其它类别文件中
+ *
+ * @param methodId 当前文件的methodId
+ * @param pasteMethodId 服务器上存在的这个要粘贴的图形的所属于的methodId
+ * @param subject 当前文件的UUID
+ * @return
+ */
+ public boolean validationPaste(String methodId, String pasteMethodId, String subject, List elementList) {
+ if (elementList == null) {
+ return false;
+ } else {
+ Set set = new HashSet();
+ int linkerCount = 0;
+ int textCount = 0;
+ for (String s : elementList) {
+ JSONObject jsonObj = JSONObject.parseObject(s);
+ if (jsonObj.containsKey("category")) {
+ set.add(jsonObj.getString("category").replace("_", "."));
+ if ("standard".equals(jsonObj.getString("category"))) {
+ textCount++;
+ }
+ }
+ if (jsonObj.containsKey("name") && "linker".equals(jsonObj.getString("name"))) {
+ linkerCount++;
+ }
+ }
+ if ((linkerCount + textCount) == elementList.size()) {// 只有箭头或插入的文本或者只包含这两者
+ return true;
+ }
+ if (set.size() == 0) {
+ return false;
+ }
+ if (methodId.equals(pasteMethodId) || set.contains(methodId)) {
+ return true;
+ } else {
+ String methodIds = PALMethodUtil.getCustom(methodId, subject);// 得到当前这个文件所关联的图形methodID
+ if (!"".equals(methodIds)) {
+ String strs[] = methodIds.split(",");
+ for (String str : strs) {
+ if (str.equals(pasteMethodId) || set.contains(str))
+ return true;
+ }
+ return false;
+ } else
+ return false;
+ }
+ }
+ }
- /**
- * 更新复制副本的内容
- *
- * @param shapeGroupId 组id
- * @param title 标题
- * @param text 文本
- * @param jsonDataArr 属性数据
- */
- private void updateShapeCache(String shapeGroupId, String title, String text, JSONArray jsonDataArr) {
- DesignerRelationShapeCacheManager cache = DesignerRelationShapeCacheManager.getInstance();
- Map> shapeMap = cache.getShapemap();
- Set key = shapeMap.keySet();
- for (String k : key) {
- Map relationShapeMap = shapeMap.get(k);
- String messageJson = (String) relationShapeMap.get("shapeCopyContent");
- if (messageJson != null) {
- JSONArray jArr = JSONArray.parseArray(messageJson);
- for (int i = 0; i < jArr.size(); i++) {
- JSONObject shape = jArr.getJSONObject(i);
- if (!"linker".equals(shape.get("name")) && shape.get("dataAttributes") != null) {
- JSONArray dataAttributes = shape.getJSONArray("dataAttributes");
- for (int j = 0; j < dataAttributes.size(); j++) {
- JSONObject attr = dataAttributes.getJSONObject(j);
- if (attr.containsKey("attributesContent") && attr.containsKey("shapeGroupId") && shapeGroupId.equals(attr.get("shapeGroupId"))) {
- if (shapeGroupId.equals(attr.get("shapeGroupId"))) {
- shape.put("text", text);
- shape.put("title", title);
- shape.put("dataAttributes", jsonDataArr);
- relationShapeMap.put("shapeCopyContent", jArr.toString());
- return;
- }
- }
- }
+ /**
+ * 校验是否是在同一资产库下,不能跨资产库复制和粘贴可以跨文件和浏览器,只限同一用户
+ *
+ * @param pasteFileUUID 服务器上缓存中的文件ID
+ * @param TargetFileUUID 粘贴的目标的源文件的ID
+ * @return boolean
+ */
+ public boolean validationIsNotSameRepository(String pasteFileUUID, String TargetFileUUID) {
+ PALRepositoryModel levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(TargetFileUUID);
+ String targetWsID = levelModel.getWsId();
+ levelModel = (PALRepositoryModel) CoeProcessLevelDaoFacotory.createCoeProcessLevel().getInstance(pasteFileUUID);
+ String pasteWsID = levelModel.getWsId();
+ if (pasteWsID.equals(targetWsID)) {
+ return true;
+ }
+ return false;
+ }
- }
- }
- }
- }
- }
+ /**
+ * 判断是不是同一用户
+ *
+ * @return
+ */
+ public boolean validationUser(Map> shapeMap, String userId) {
+ if (!shapeMap.isEmpty()) {
+ Set set = shapeMap.keySet();
+ for (String u : set) {
+ if (u.equals(userId)) {// 如果是同一用户,则将最后一次复制的内容更新到同一用户对应的缓存中
+ return true;
+ }
+ }
+ }
+ return false;
+ }
- /**
- * 判断新的数据和旧的数据是否相同
- * fastjson
- *
- * @param dataAttributes1
- * @param dataAttributes2
- * @return
- */
- private boolean isTheSame(JSONArray dataAttributes1, JSONArray dataAttributes2) {
- String attributesContent = "";
- String linksArray = "";
- String privateAttribute = "";
- String attributesJsonArray = "";
- String privateAttributeContent = "";
- String shapeDesc = "";
- String upFilesArray = "";
- String relevanceShapes = "";
- for (int i = 0; i < dataAttributes1.size(); i++) {
- JSONObject attr = dataAttributes1.getJSONObject(i);
- if (attr.containsKey("attributesContent")) {
- attributesContent = attr.getString("attributesContent");
- linksArray = attr.getJSONArray("linksArray").toString();
- attributesJsonArray = attr.getJSONArray("attributesJsonArray").toString();
- privateAttribute = attr.getString("privateAttribute");
- privateAttributeContent = attr.getString("privateAttributeContent");
- shapeDesc = attr.getString("shapeDesc");
- if (attr.containsKey("upFilesArray")) {
- upFilesArray = attr.getJSONArray("upFilesArray").toString();
- }
- if (attr.containsKey("relevanceShapes")) {
- relevanceShapes = attr.getJSONArray("relevanceShapes").toString();
- }
- }
- }
- String attributesContent1 = "";
- String linksArray1 = "";
- String privateAttribute1 = "";
- String attributesJsonArray1 = "";
- String privateAttributeContent1 = "";
- String shapeDesc1 = "";
- String upFilesArray1 = "";
- String relevanceShapes1 = "";
- for (int i = 0; i < dataAttributes2.size(); i++) {
- JSONObject attr = dataAttributes2.getJSONObject(i);
- if (attr.containsKey("attributesContent")) {
- attributesContent1 = attr.getString("attributesContent");
- linksArray1 = attr.getJSONArray("linksArray").toString();
- attributesJsonArray1 = attr.getJSONArray("attributesJsonArray").toString();
- privateAttribute1 = attr.getString("privateAttribute");
- privateAttributeContent1 = attr.getString("privateAttributeContent");
- shapeDesc1 = attr.getString("shapeDesc");
- if (attr.containsKey("upFilesArray")) {
- upFilesArray1 = attr.getJSONArray("upFilesArray").toString();
- }
- if (attr.containsKey("relevanceShapes")) {
- relevanceShapes1 = attr.getJSONArray("relevanceShapes").toString();
- }
- }
- }
- if (relevanceShapes1.equals(relevanceShapes) && attributesContent1.equals(attributesContent) && linksArray1.equals(linksArray) && attributesJsonArray1.equals(attributesJsonArray) && privateAttribute1.equals(privateAttribute) && privateAttributeContent1.equals(privateAttributeContent) && shapeDesc1.equals(shapeDesc) && upFilesArray1.equals(upFilesArray)) {
- return true;
- }
- return false;
- }
+ /**
+ * 将第一次复制的数据插入到数据库
+ *
+ * @param elementList
+ * @param subject
+ * @return
+ */
+ public boolean copyToDatabase(List elementList, String subject) {
+ List list = new ArrayList();
+ for (int i = 0; i < elementList.size(); i++) {
+ String messageJson = elementList.get(i);
+ JSONObject jsonObj = JSONObject.parseObject(messageJson);
+ // 对连线不作任何操作
+ if ("linker".equals(jsonObj.getString("name"))) {
+ continue;
+ }
+ Map map = ShapeUtil.getIsCopy(messageJson);
+ String shapeGroupId = map.get("shapeGroupId");
+ String isCopy = map.get("isCopy");
+ if ("N".equals(isCopy)) {
+ continue;
+ }
+ DesignerShapeCopyModel model = new DesignerShapeCopyModel();
+ model.setShapeId(jsonObj.getString("id"));
+ model.setShapeGroupId(shapeGroupId);
+ model.setShapeMessage(elementList.get(i));
+ model.setShapecategoryName(jsonObj.getString("category"));
+ model.setShapeName(jsonObj.getString("name"));
+ model.setisCopy(isCopy);
+ model.setPalRepositoryId(subject);
+ model.setShapeType(jsonObj.getString("title"));
+ model.setIsDelete("N");
+ list.add(model);
+ }
+ try {
+ return CoeProcessLevelDaoFacotory.createCoeProcessLevel().createShape(list);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
- /**
- * 更新出现复制过的文件的的信息
- *
- * @param fileIdList
- * @throws UnsupportedEncodingException
- */
- private void updateFile(Set