Exemple #1
0
 @Override
 public void initialize(Settings settings, StorageEngine store) throws Exception {
   this.settings = settings;
   this.store = store;
   restAccess =
       new JiraRestAccess(
           settings.getJiraUrl(), settings.getJiraUser(), settings.getJiraPassword());
   ClientResponse response = restAccess.get("/myself");
   if (response.getStatus() != Status.OK.getStatusCode()) {
     throw new RuntimeException("Unable to connect to jira repository: " + response.toString());
   }
   this.projectOptional = getProject();
 }
Exemple #2
0
  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;
  }
Exemple #3
0
 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);
   }
 }
Exemple #4
0
 @Override
 public boolean isConfigured() {
   return Settings.getInstance().hasJiraProperties();
 }
Exemple #5
0
 private Optional<Project> getProject() {
   return Optional.ofNullable(
       restAccess.get("/project/" + settings.getJiraProjectKey(), Project.class));
 }