Issue createIssueFromWorkItem(ODocument workItem, Project project) { Issue issue = new Issue(); IssueFields issueFields = issue.getFields(); issueFields.setProject(project); for (Entry<String, Object> entry : workItem) { mappingRegistry.map(entry, issue, store); String field = entry.getKey(); switch (field) { case ID: String id = (String) entry.getValue(); issue.setId(id); break; case DESCRIPTION: String htmlText = (String) entry.getValue(); // TODO: replace HTML style formatting with JIRA formatting issueFields.setDescription(htmlText); break; case WORK_ITEM_TYPE: String workitemType = (String) entry.getValue(); switch (workitemType) { case TASK: issueFields.setIssuetype(getIssueType("Task", project)); break; case STORY: issueFields.setIssuetype(getIssueType("User Story", project)); break; case EPIC: issueFields.setIssuetype(getIssueType("Epic", project)); break; case BUSINESSNEED: issueFields.setIssuetype(getIssueType("Business Need", project)); break; case DEFECT: issueFields.setIssuetype(getIssueType("Bug", project)); break; default: LOGGER.warning( "Cannot determine issuetype for unknown workitemType: " + workitemType); break; } break; default: break; } } issueFields.setSummary(issue.getId() + ": " + issueFields.getSummary()); issue.setId(StorageQuery.getField(workItem, FieldNames.JIRA_ID_LINK, "")); issue.setKey(settings.getJiraProjectKey() + '-' + workItem.field(FieldNames.ID)); return issue; }
private void createDummyIssues() { if (projectOptional.isPresent()) { Project project = projectOptional.get(); Issue issue = new Issue(); issue.getFields().setProject(project); issue.getFields().setIssuetype(getIssueType("Task", project)); issue.getFields().setSummary("Dummy"); issue .getFields() .setDescription( "This is just a dummy issue. Delete it after successfully migrating to Jira."); Issue createdIssue = createIssueInJira(issue); String highestAsString = createdIssue.getKey().replace(settings.getJiraProjectKey() + '-', ""); highestExistingId = Integer.parseInt(highestAsString); } }
private Optional<Project> getProject() { return Optional.ofNullable( restAccess.get("/project/" + settings.getJiraProjectKey(), Project.class)); }