示例#1
0
 @Override
 public void createOrUpdateItem(ODocument item) throws Exception {
   String workItemId = item.field(FieldNames.ID);
   ensureWorkItemWithId(Integer.parseInt(workItemId));
   Date modified = StorageQuery.getField(item, FieldNames.MODIFIED, Date.from(Instant.now()));
   Date lastExport = StorageQuery.getField(item, FieldNames.JIRA_EXPORT_TIMESTAMP, new Date(0));
   if (modified.compareTo(lastExport) > 0) {
     updateItem(item);
   }
 }
示例#2
0
 void storeTimestampOfLastExport(ODocument workItem) {
   store.setFields(
       workItem, //
       of(
           FieldNames.JIRA_EXPORT_TIMESTAMP,
           StorageQuery.getField(workItem, FieldNames.MODIFIED, Date.from(Instant.now()))));
 }
示例#3
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;
  }