ExportFieldValue
In order to convert the
Codebeamer field value, such as Wiki markup, into the appropriate JIRA custom field value, such as an
array of checklist items
, your
@CustomField extension must provide a
@CustomField.ExportFieldValue method
.
The method must return the specified Codebeamer field value, converted into the appropriate JIRA custom field value.
The method has access to the following context information using parameters of the appropriate type:
• JiraImportController, to receive the controller of the current JIRA export.
• ProjectConfiguration or ProjectDto, to receive the source project of the JIRA export.
• JiraTrackerSyncConfig, to receive the source tracker of the JIRA export.
• TrackerItemDto, to receive the source tracker item from which the custom field value comes.
• TrackerLayoutLabelDto, to receive the source field from which the value comes.
• @CustomField.type, to receive the source field value to export.
• JiraRestClient, to receive the REST API of the remote JIRA instance from which to import.
• ImporterSupport, to receive the current importer
• TrackerItemFieldHandler, to receive the handler for the current tracker item field.
package com.intland.codebeamer.controller.jira;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.node.JsonNode;
import com.intland.codebeamer.controller.jira.CustomField;
import com.intland.codebeamer.controller.jira.JiraImportController;
import com.intland.codebeamer.controller.jira.JiraTrackerSyncConfig;
import com.intland.codebeamer.persistence.dto.TrackerLayoutLabelDto;
import com.intland.codebeamer.wiki.plugins.ChecklistPlugin;
@Component("com.okapya.jira.checklist:checklist")
@CustomField(type="WikiText", of="Checklist")
public class ChecklistForJiraField {
/**
* Convert a {@link ChecklistPlugin} body into a
* <a href="https://okapya.atlassian.net/wiki/spaces/CHKDOC/pages/270172389/Modifying+Checklists+using+a+REST+API">Checklist for JIRA<a>
* @param tracker is the JIRA tracker sync configuration
* @param checklist is the {@link ChecklistPlugin} body
* @return the converted {@link ChecklistPlugin} body
*/
public JsonNode cb2jira(JiraTrackerSyncConfig tracker, JsonNode checklist) {
...
}
@CustomField.ExportFieldValue
public JsonNode exportChecklist(JiraTrackerSyncConfig tracker, String markup) {
return cb2jira(tracker, ChecklistPlugin.unwrap(markup));
}
}
During the import, the
Checklist for Jira
extension converts the
Array of checklist items
into an array of
Checklist Plugin items using
jira2cb() and wraps them into
Checklist Plugin markup. During the export, the
Checklist Plugin body is unwrapped and then converted into an
Array of checklist items
using
cb2jira(). This also converts
Codebeamer Wiki Markup back into the special
Checklist for Jira
Markdown syntax
(see
attached example source code).
If the JIRA field value would use standard
JIRA Wiki markup
, your extension should use
JiraImportController.exportWikiText(String markup, JiraRestClient restApi, to convert
Codebeamer Wiki Markup into
JIRA Wiki markup
.