ImportFieldValue
In order to convert the JIRA custom field value, e.g. Array of checklist items, into the appropriate Codebeamer field value, e.g. Wiki markup, your @CustomField extension must provide a @CustomField.ImportFieldValue method.
The method must return the passed in JIRA field value (provided in it's 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 via 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, where the custom field value should be stored into
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 to import from
ImporterSupport, to receive the current importer
ImportStatistics, to receive the current import statistics
TrackerItemFieldHandler, to receive the current tracker item field handler
For example: Checklist for Jira:


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 (via jira2cb()) and wraps them into Checklist Plugin markup. The Checklist Plugin is also a custom Codebeamer Wiki Plugin, whose example source code is attached.
Please also note, that Checklist for Jira uses its own Markdown syntax, so checklist item names must be converted from this special markdown to Codebeamer Wiki Markup as well (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.
Was this helpful?