ImportFinished
如果要在完成项的导入处理后调用
@CustomField 扩展,该扩展可以提供一种
@CustomField.ImportFinished方法
。
该方法可使用相应类型的参数访问以下上下文信息:
• JiraImportController - 用于接收当前 JIRA 导入的控制器。
• ProjectConfiguration 或 ProjectDto - 用于接收 JIRA 导入的目标项目。
• JiraTrackerSyncConfig - 用于接收 JIRA 导入的目标跟踪器。
• TrackerItemDto - 用于接收已完成导入的目标跟踪器项。
• TrackerLayoutLabelDto - 用于接收已导入字段值的目标字段。
• JiraRestClient - 用于接收要从中导入的远程 JIRA 实例的 REST API。
• ImporterSupport - 用于接收当前导入器。
• ImportStatistics - 用于接收当前导入统计信息。
• TrackerItemFieldHandler - 用于接收当前跟踪器项字段的处理器。
对于与 @CustomField 扩展关联的每个导入项和每个项字段,都会调用一次此方法。
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.manager.util.ImporterSupport;
import com.intland.codebeamer.persistence.dto.TrackerItemDto;
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 {
/**
* Remove the cached checklist for the specified field of the specified item, after the item import is finished
* @param item is the current tracker item to import
* @param field is the checklist field
* @param importer is the current import cache/support
*/
@CustomField.ImportFinished
public void resetChecklist(TrackerItemDto item, TrackerLayoutLabelDto field, ImporterSupport importer) {
Map<Integer,JsonNode> checklists = getChecklists(importer, false);
if (checklists != null) {
if (field != null) {
checklists.remove(field.getId());
} else {
checklists.clear();
}
}
}
}
ChecklistForJira 扩展需要在每个项之后重置每个字段的核对清单值缓存。