private void updateTimeSpent(MutableIssue issue, String fieldValue, List changeItems, Map transientVars) { try { Long oldTimeSpent = issue.getTimeSpent(); Long newTimeSpent = new Long(fieldValue); if (!Objects.equal(oldTimeSpent, newTimeSpent)) { issue.setTimeSpent(newTimeSpent); String from = null; String fromString = null; String to = null; String toString = null; if (oldTimeSpent != null) { from = fromString = oldTimeSpent.toString(); } if (newTimeSpent != null) { to = toString = newTimeSpent.toString(); } changeItems.add(new ChangeItemBean(ChangeItemBean.STATIC_FIELD, IssueFieldConstants.TIME_SPENT, from, fromString, to, toString)); transientVars.put("changeItems", changeItems); } } catch (NumberFormatException e) { log.error("Cannot update field '" + IssueFieldConstants.TIME_SPENT + "' to '" + fieldValue + "' as the value must be numeric."); } }
private void setNotCloningFieldsToBlankByDefault() { getIssueObject().setCreated(null); getIssueObject().setUpdated(null); getIssueObject().setVotes(null); getIssueObject().setWatches(0L); getIssueObject().setStatus(null); getIssueObject().setWorkflowId(null); // Ensure that the 'time spent' and 'remaining estimated' are not cloned - JRA-7165 // We need to copy the value of 'original estimate' to the value 'remaining estimate' as they must be kept in sync // until work is logged on an issue. getIssueObject().setEstimate(getOriginalIssue().getOriginalEstimate()); getIssueObject().setTimeSpent(null); //JRA-18731: Cloning a resolved issue will result in an open issue. The resolution date should be reset. getIssueObject().setResolutionDate(null); // If the user does not have permission to modify the reporter, initialise the reporter to be the remote user if (!isCanModifyReporter()) { getIssueObject().setReporter(getLoggedInUser()); } }
Issue createIssueForExternalIssue(final ExternalIssue externalIssue) { final MutableIssue issue = issueFactory.getIssue(); issue.setProjectId(new Long(externalIssue.getProject())); issue.setIssueTypeId(externalIssue.getIssueType()); issue.setReporterId(externalIssue.getReporter()); issue.setAssigneeId(externalIssue.getAssignee()); issue.setSummary(externalIssue.getSummary()); issue.setDescription(externalIssue.getDescription()); issue.setEnvironment(externalIssue.getEnvironment()); issue.setPriorityId(externalIssue.getPriority()); issue.setResolutionId(externalIssue.getResolution()); issue.setCreated(toTimeStamp(externalIssue.getCreated())); issue.setUpdated(toTimeStamp(externalIssue.getUpdated())); issue.setDueDate(toTimeStamp(externalIssue.getDuedate())); //NOTE: This HAS to come after the setResolutionId() call, otherwise that will override this date. issue.setResolutionDate(toTimeStamp(externalIssue.getResolutionDate())); issue.setVotes(externalIssue.getVotes()); issue.setOriginalEstimate(externalIssue.getOriginalEstimate()); issue.setTimeSpent(externalIssue.getTimeSpent()); issue.setEstimate(externalIssue.getEstimate()); if (externalIssue.getSecurityLevel() != null) { issue.setSecurityLevelId(new Long(externalIssue.getSecurityLevel())); } return issue; }