/** * A Check if we should consider two beans the same * * @param * @return */ @Override public boolean considerAsSame( ISerializableLabelBean serializableLabelBean, Map<String, Map<Integer, Integer>> matchesMap) { if (serializableLabelBean == null) { return false; } TScreenPanelBean screenPanelBean = (TScreenPanelBean) serializableLabelBean; String externalUuid = getUuid(); String internalUuid = screenPanelBean.getUuid(); if (EqualUtils.equalStrict(externalUuid, internalUuid)) { return true; } /// return false; }
/** * Validates the workItemLink before save * * @param workItemLinkBean * @param workItemLinkOriginal * @param workItemsLinksMap * @param predWorkItem * @param succWorkItem * @param personBean * @param locale * @return */ @Override public List<ErrorData> validateBeforeSave( TWorkItemLinkBean workItemLinkBean, TWorkItemLinkBean workItemLinkOriginal, SortedMap<Integer, TWorkItemLinkBean> workItemsLinksMap, TWorkItemBean predWorkItem, TWorkItemBean succWorkItem, TPersonBean personBean, Locale locale) { List<ErrorData> errorDataList = new LinkedList<ErrorData>(); Integer linkPred = workItemLinkBean.getLinkPred(); Integer linkSucc = workItemLinkBean.getLinkSucc(); if (linkPred == null || linkSucc == null) { // add link to a new item boolean linkedIsSuccessor = false; if (linkSucc != null) { linkedIsSuccessor = true; } else { if (linkPred != null) { linkedIsSuccessor = false; } } Integer newLinkedItemID = getLinkedItem(workItemLinkBean, linkedIsSuccessor); Integer newlinkType = workItemLinkBean.getLinkType(); Integer newLinkDirection = workItemLinkBean.getLinkDirection(); if (newLinkedItemID != null) { if (workItemsLinksMap != null) { for (TWorkItemLinkBean addedWorkItemLinkBean : workItemsLinksMap.values()) { Integer addedLinkedItemID = getLinkedItem(addedWorkItemLinkBean, linkedIsSuccessor); if (EqualUtils.equal(newLinkedItemID, addedLinkedItemID) && EqualUtils.equal(newlinkType, addedWorkItemLinkBean.getLinkType())) { // duplicate link for new item if (EqualUtils.equal(newLinkDirection, addedWorkItemLinkBean.getLinkDirection())) { errorDataList.add(new ErrorData("item.tabs.itemLink.err.linkExists")); } else { errorDataList.add(new ErrorData("item.tabs.itemLink.err.circularDependency")); } return errorDataList; } } } } // no duplicate link for new item return errorDataList; } Integer linkTypeID = workItemLinkBean.getLinkType(); Integer newLinkDirection = workItemLinkBean.getLinkDirection(); List<Integer> linkTypeIDs = new LinkedList<Integer>(); linkTypeIDs.add(linkTypeID); // link with the same linkTypeID can't be duplicated List<TWorkItemLinkBean> existingLinks = ItemLinkBL.loadLinksOfWorkItems( workItemLinkBean.getObjectID(), linkPred, linkSucc, linkTypeIDs); boolean linkExists = existingLinks != null && !existingLinks.isEmpty(); if (linkExists) { TWorkItemLinkBean existingLinkBean = existingLinks.get(0); if (EqualUtils.equal(newLinkDirection, existingLinkBean.getLinkDirection())) { errorDataList.add(new ErrorData("item.tabs.itemLink.err.linkExists")); } else { errorDataList.add(new ErrorData("item.tabs.itemLink.err.circularDependency")); } } List<TWorkItemLinkBean> reverseLinks = ItemLinkBL.loadLinksOfWorkItems( workItemLinkBean.getObjectID(), linkSucc, linkPred, linkTypeIDs); boolean reverseLinkExists = reverseLinks != null && !reverseLinks.isEmpty(); if (reverseLinkExists) { TWorkItemLinkBean existingLinkBean = reverseLinks.get(0); if (EqualUtils.equal(newLinkDirection, existingLinkBean.getLinkDirection())) { errorDataList.add(new ErrorData("item.tabs.itemLink.err.circularDependency")); } else { errorDataList.add(new ErrorData("item.tabs.itemLink.err.linkExists")); } } return errorDataList; }