/** * Method getOriginalAnomaly. * * @param aOriginalReview R4EReview * @param aCurrentAnomaly R4EAnomaly * @return R4EAnomaly */ public static R4EAnomaly getOriginalAnomaly( R4EReview aOriginalReview, R4EAnomaly aCurrentAnomaly) { if ((null != aOriginalReview) && (null != aCurrentAnomaly)) { // Loop through all anomalies and find the one whose R4EID is the same as the currently // imported one final String[] origIdTokens = aCurrentAnomaly .getInfoAtt() .get(R4EUIConstants.POSTPONED_ATTR_ORIG_ANOMALY_ID) .split( R4EUIConstants .SEPARATOR); // First token is user name, second token is sequence number if (null != origIdTokens) { final R4EUser origUser = aOriginalReview.getUsersMap().get(origIdTokens[0]); if (null != origUser) { for (R4EComment anomaly : origUser.getAddedComments()) { if (anomaly instanceof R4EAnomaly) { Integer id = Integer.valueOf(origIdTokens[1]); if (null != id) { if (id.intValue() == anomaly.getId().getSequenceID()) { return (R4EAnomaly) anomaly; } } } } } } } return null; }
/** * Method getAnomalyPosition. * * @param aAnomaly R4EAnomaly * @return R4EAnomalyTextPosition */ public static R4EAnomalyTextPosition getAnomalyPosition(R4EAnomaly aAnomaly) { if (null != aAnomaly) { final EList<Location> location = aAnomaly.getLocation(); if ((null != location) && (location.size() > 0)) { final R4EContent content = (R4EContent) location.get(0); // look at first location only if (null != content) { final R4EAnomalyTextPosition position = (R4EAnomalyTextPosition) content.getLocation(); return position; } } } return null; }
/** * Method buildOriginalAnomalyID. * * @param aOrigAnomaly R4EAnomaly * @return String */ public static String buildOriginalAnomalyID(R4EAnomaly aOrigAnomaly) { return aOrigAnomaly.getId().getUserID() + R4EUIConstants.SEPARATOR + aOrigAnomaly.getId().getSequenceID(); }
/** * Method copyAnomalyData. * * @param aTargetAnomaly R4EAnomaly * @param aSourceAnomaly R4EAnomaly * @throws ResourceHandlingException * @throws OutOfSyncException */ public static void copyAnomalyData(R4EAnomaly aTargetAnomaly, R4EAnomaly aSourceAnomaly) throws ResourceHandlingException, OutOfSyncException { if ((null != aTargetAnomaly) && (null != aSourceAnomaly)) { final Long bookNum = R4EUIModelController.FResourceUpdater.checkOut( aTargetAnomaly, R4EUIModelController.getReviewer()); // Data copied unconditionally aTargetAnomaly.setCreatedOn(aSourceAnomaly.getCreatedOn()); aTargetAnomaly.setDecidedByID(aSourceAnomaly.getDecidedByID()); aTargetAnomaly.setFixedByID(aSourceAnomaly.getFixedByID()); aTargetAnomaly.setFollowUpByID(aSourceAnomaly.getFollowUpByID()); aTargetAnomaly.setState(aSourceAnomaly.getState()); aTargetAnomaly.setFixedInVersion(aSourceAnomaly.getFixedInVersion()); aTargetAnomaly.setNotAcceptedReason(aSourceAnomaly.getNotAcceptedReason()); // Data copied only if not set previously if (null == aTargetAnomaly.getTitle() || ("").equals(aTargetAnomaly.getTitle())) { aTargetAnomaly.setTitle(aSourceAnomaly.getTitle()); } if (null == aTargetAnomaly.getDescription() || ("").equals(aTargetAnomaly.getDescription())) { aTargetAnomaly.setDescription(aSourceAnomaly.getDescription()); } if (null == aTargetAnomaly.getRank()) { aTargetAnomaly.setRank(aSourceAnomaly.getRank()); } if (null == aTargetAnomaly.getRuleID() && null != aSourceAnomaly.getRuleID()) { aTargetAnomaly.setRuleID(aSourceAnomaly.getRuleID()); } if (null != aSourceAnomaly.getType()) { final R4ECommentType oldCommentType = (R4ECommentType) aSourceAnomaly.getType(); R4ECommentType commentType = (R4ECommentType) aTargetAnomaly.getType(); if (null != oldCommentType) { if (null == commentType) { commentType = RModelFactory.eINSTANCE.createR4ECommentType(); if (null != commentType) { commentType.setType(oldCommentType.getType()); } aTargetAnomaly.setType(commentType); } } } R4EUIModelController.FResourceUpdater.checkIn(bookNum); } }