ImportFieldValue
In order to convert the JIRA custom field value, such as an
array of checklist items
, into the appropriate
Codebeamer field value, such as Wiki markup, your
@CustomField extension must provide a
@CustomField.ImportFieldValue method
.
The method must return the passed-in JIRA field value in its
JSON
form converted into the
Codebeamer @CustomField.type.
If the Jira custom field value might contain 4-byte
UTF-8
characters, it is necessary to pass such Strings through
JiraImportController.check4ByteChars(string).
The method has access to the following context information using parameters of the appropriate type:
• JiraImportController, to receive the controller of the current JIRA import.
• ProjectConfiguration or ProjectDto, to receive the target project of the JIRA import.
• JiraTrackerSyncConfig, to receive the target tracker of the JIRA import
• TrackerItemDto, to receive the target tracker item, into which the custom field value should be stored.
• TrackerLayoutLabelDto, to receive the target field, whose value to import
• JsonNode, to receive the JIRA custom field value as provided by the JIRA REST API to import.
• JiraRestClient, to receive the REST API of the remote JIRA instance from which to import.
• ImporterSupport, to receive the current importer.
• ImportStatistics, to receive the current import statistics.
• 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.wiki.plugins.ChecklistPlugin;
@Component("com.okapya.jira.checklist:checklist")
@CustomField(type="WikiText", of="Checklist")
public class ChecklistForJiraField {
/**
* Convert a <a href="https://okapya.atlassian.net/wiki/spaces/CHKDOC/pages/270172389/Modifying+Checklists+using+a+REST+API">Checklist for JIRA<a>
* into a {@link ChecklistPlugin} body
* @param tracker is the JIRA tracker sync configuration
* @param checklist is the checklist as returned from Jira
* @param controller to {@link JiraImportController#check4ByteChars(String)}
* @return the checklist converted into a {@link ChecklistPlugin} body
*/
public JsonNode jira2cb(JiraTrackerSyncConfig tracker, JsonNode checklist, JiraImportController controller) {
...
}
@CustomField.ImportFieldValue
public String importChecklist(JiraTrackerSyncConfig tracker, JsonNode checklist, JiraImportController controller) {
return ChecklistPlugin.wrapChecklist(jira2cb(tracker, checklist, controller));
}
}
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. The
Checklist Plugin is also a custom
Codebeamer Wiki Plugin, whose example source code is
attached.
Note, that the
Checklist for Jira
extension uses its own
markdown syntax
. Checklist item names must be converted from this special markdown to
Codebeamer Wiki Markup. This happens in
jira2cb() and is not shown here, but the example source code is
attached).
If the JIRA field value would contain standard
JIRA Wiki markup
, your extension should use
JiraImportController.convertWikiText(String text, String dflt)to convert it into
Codebeamer Wiki Markup.