public String getColumnViewHtml(FieldLayoutItem fieldLayoutItem, Map displayParams, Issue issue) { Map<String, Object> velocityParams = getVelocityParams(fieldLayoutItem, null, issue, displayParams); LinkCollection linkCollection = issueLinkManager.getLinkCollection(issue, authenticationContext.getLoggedInUser()); velocityParams.put("linkedIssues", linkCollection.getAllIssues()); velocityParams.put("applicationProperties", getApplicationProperties()); return renderTemplate("issuelinks-columnview.vm", velocityParams); }
@Override public FieldJsonRepresentation getJsonFromIssue( Issue issue, boolean renderedVersionRequired, FieldLayoutItem fieldLayoutItem) { if (!issueLinkManager.isLinkingEnabled()) { return null; } IssueLinksBeanBuilder builder = issueLinkBeanBuilderFactory.newIssueLinksBeanBuilder(issue); return new FieldJsonRepresentation(new JsonData(builder.buildIssueLinks())); }
private void baseMockSetup() throws GenericEntityException, RemoveException, IndexException { expect(mailThreadManager.removeAssociatedEntries(ISSUE_ID)).andReturn(1); expect(mockIssueLinkManager.removeIssueLinks(issueGenericValue, (User) null)).andReturn(1); expect(attachmentManager.getAttachments(issue)).andReturn(ImmutableList.of(attachment)); expect(mockIssueManager.getIssueObject(ISSUE_ID)).andReturn(issue); associationManager.removeAssociationsFromSource(issueGenericValue); expectLastCall(); associationManager.removeUserAssociationsFromSink(issueGenericValue); expectLastCall(); customFieldManager.removeCustomFieldValues(issueGenericValue); expectLastCall(); attachmentManager.deleteAttachment(attachment); expectLastCall(); attachmentManager.deleteAttachmentDirectory(issue); expectLastCall(); workflowManager.removeWorkflowEntries(issueGenericValue); expectLastCall(); indexManager.deIndex(issueGenericValue); expectLastCall(); changeHistoryManager.removeAllChangeItems(issue); expectLastCall(); stubEventManager(); }
@EventListener public void onIssueEvent(IssueEvent issueEvent) { if (!issueEvent.getEventTypeId().equals(EventType.ISSUE_CREATED_ID)) { return; } Issue issue = issueEvent.getIssue(); Collection<ProjectComponent> comps = issue.getComponentObjects(); if (comps == null || comps.size() < 2) { return; } Project project = issue.getProjectObject(); if (project == null || !isApplyPlugin(project.getId())) { return; } List<Issue> newIssues = new ArrayList<Issue>(); ProjectComponent gv = null; Iterator<ProjectComponent> iter = comps.iterator(); while (iter.hasNext()) { gv = iter.next(); MutableIssue nissue = ComponentManager.getInstance().getIssueFactory().getIssue(); // --> summary nissue.setSummary(String.format("[%s] %s", gv.getName(), issue.getSummary())); // --> project if (issue.getProjectObject() != null) { nissue.setProjectId(issue.getProjectObject().getId()); } // --> issue type if (issue.getIssueTypeObject() != null) { nissue.setIssueTypeId(issue.getIssueTypeObject().getId()); } // --> components Collection<ProjectComponent> nComps = new LinkedList<ProjectComponent>(); nComps.add(gv); nissue.setComponentObjects(nComps); // --> assignee String compLead = gv.getLead(); nissue.setAssigneeId(compLead); // --> reporter nissue.setReporter(issueEvent.getUser()); // --> priority nissue.setPriorityObject(issue.getPriorityObject()); // --> description nissue.setDescription(issue.getDescription()); // --> env nissue.setEnvironment(issue.getEnvironment()); // --> due date nissue.setDueDate(issue.getDueDate()); // --> estimate nissue.setEstimate(issue.getEstimate()); // --> labels nissue.setLabels(issue.getLabels()); nissue.setAffectedVersions(issue.getAffectedVersions()); nissue.setWorkflowId(issue.getWorkflowId()); nissue.setParentId(issue.getParentId()); // --> status if (issue.getStatusObject() != null) { nissue.setStatusId(issue.getStatusObject().getId()); } // --> resolution if (issue.getResolutionObject() != null) { nissue.setResolutionId(issue.getResolutionObject().getId()); } nissue.setFixVersions(issue.getFixVersions()); nissue.setResolutionDate(issue.getResolutionDate()); nissue.setTimeSpent(issue.getTimeSpent()); nissue.setVotes(issue.getVotes()); nissue.setCreated(issue.getCreated()); nissue.setSecurityLevelId(issue.getSecurityLevelId()); nissue.setOriginalEstimate(issue.getOriginalEstimate()); List<CustomField> cfs = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObjects(issue); if (cfs != null) { for (CustomField cf : cfs) { Object cfVal = issue.getCustomFieldValue(cf); if (cfVal != null) { nissue.setCustomFieldValue(cf, cfVal); } } } // --> create issue try { Issue newIssueObj = ComponentManager.getInstance() .getIssueManager() .createIssueObject(issueEvent.getUser(), nissue); newIssues.add(newIssueObj); } catch (CreateException crex) { log.error("IssueClonerByComponents::onIssueEvent - Cannot create dependent issues", crex); } } Collection<Attachment> atts = issue.getAttachments(); if (atts != null) { AttachmentManager am = ComponentManager.getInstance().getAttachmentManager(); for (Attachment att : atts) { File attFile = AttachmentUtils.getAttachmentFile(att); String filename = att.getFilename(); String contentType = att.getMimetype(); for (Issue nissue : newIssues) { File newFile = new File(attFile.getAbsolutePath() + nissue.getKey()); try { FileUtils.copyFile(attFile, newFile); am.createAttachment(newFile, filename, contentType, issueEvent.getUser(), nissue); } catch (Exception ex) { log.error("IssueClonerByComponents::onIssueEvent - Cannot copy attachment", ex); } } } } IssueLinkTypeManager issueLinkTypeManager = ComponentManager.getComponentInstanceOfType(IssueLinkTypeManager.class); Collection<IssueLinkType> types = issueLinkTypeManager.getIssueLinkTypesByName(LINK_TYPE); if (types == null || types.isEmpty()) { return; } IssueLinkType ilt = types.iterator().next(); if (ilt != null) { IssueLinkManager ilm = ComponentManager.getInstance().getIssueLinkManager(); for (Issue nissue : newIssues) { try { ilm.createIssueLink( issue.getId(), nissue.getId(), ilt.getId(), null, issueEvent.getUser()); } catch (CreateException crex) { log.error("IssueClonerByComponents::onIssueEvent - Cannot create link", crex); } } } }