ImportFieldHistoryValue
To import the JIRA issue changelog, the JIRA changelog entries, must be converted into appropriate Codebeamer TrackerItemHistoryConfiguration.
For example,status which is single value field:

{

"from" : "10000",

"fromString" : "To Do",

"to" : "3",

"toString" : "In Progress"

}

The changes op for the TrackerItemHistoryConfiguration should be Set and the oldValue and newValue should be the old and new status.
For example assignee which is multiple value field:


{

"from" : null,

"fromString" : null,

"to" : "lzoltan",

"toString" : "Luspai Zoltan"

}

JIRA typically provides multiple changelog entries for following values:
Added: from: null and to: not null
Removed: from: not null and to : null
In this case, the resulting change op for theTrackerItemHistoryConfiguration should be Add which is the newValue or Remove which is the oldValue.
Each JIRA custom field can write any value in to JIRA changelog.
For example for the Checklist for Jira extension, although the JIRA field is defined to be an Array of checklist items, only a single changelog entry is provided. That entry can contain any number of checklist changes, as a multi-line string, where an (x) at the start of a new line marks the begin of the xth. change.


{

"from" : null,

"fromString": "1) [Checked] Deploy to staging server\n\r2) [Checked] Pull request",

"to" : null,

"toString" : "1) [Status changed, Unchecked] (In Progress) Deploy to staging server\n\r2) [Unchecked] Pull request"

}

In order to decode the following from a JIRA custom field changelog:
from and fromString into the oldValue for the Codebeamer TrackerItemHistoryConfiguration.
to and toString into the newValue for the Codebeamer TrackerItemHistoryConfiguration.
a @CustomField extension can provide a @CustomField.ImportFieldHistoryValuemethod that is called twice for each JIRA changelog entry.
1. Once with "from" and "fromString" to get the oldValue for the Codebeamer TrackerItemHistoryConfiguration.
2. Once with "to" and "toString" to get the newValue for the Codebeamer TrackerItemHistoryConfiguration.
If the JIRA changelog string contains 4-byte UTF-8 characters, such strings must be passed 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 "from"/"to" JSON value of the changelog entry to import
String, to receive the "fromString"/"toString" String value of the changelog entry 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
For example, the following code from the Checklist for Jira extension parses the change log item string into a Map of Changes per Change ID.


package com.intland.codebeamer.controller.jira;

import org.springframework.stereotype.Component;

import com.intland.codebeamer.controller.jira.CustomField;
import com.intland.codebeamer.controller.jira.JiraImportController;
import com.intland.codebeamer.wiki.plugins.ChecklistPlugin;

@Component("com.okapya.jira.checklist:checklist")

@CustomField(type="WikiText", of="Checklist")

public class ChecklistForJiraField {


/**

* Parse the information about JIRA checklist changes from a JIRA issue changelog <code>fromString</code> or <code>toString</code>

* @param lines is a <code>fromString</code> or <code>toString</code>, that can contain multiple lines of checklist changes, one line per changed checklist item

* @param controller to {@link JiraImportController#check4ByteChars(String)}, or null

* @return a Map of the parsed checklist item changes

*/

@CustomField.ImportFieldHistoryValue

public Map<Integer,Change> getItemChanges(String lines, JiraImportController controller) {

Map<Integer,Change> result = ...

return result;

}

}
* 
The code shown above does not provide a valid oldValue or newValue for a Codebeamer Checklist history entry, because a checklist field is a single value Wikitext field. The oldValue and newValue must be provided in Checklist Wiki markup.
Was this helpful?