in src/main/java/org/opensearch/ad/model/ADTask.java [380:452]
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
XContentBuilder xContentBuilder = builder.startObject();
if (taskId != null) {
xContentBuilder.field(TASK_ID_FIELD, taskId);
}
if (lastUpdateTime != null) {
xContentBuilder.field(LAST_UPDATE_TIME_FIELD, lastUpdateTime.toEpochMilli());
}
if (startedBy != null) {
xContentBuilder.field(STARTED_BY_FIELD, startedBy);
}
if (stoppedBy != null) {
xContentBuilder.field(STOPPED_BY_FIELD, stoppedBy);
}
if (error != null) {
xContentBuilder.field(ERROR_FIELD, error);
}
if (state != null) {
xContentBuilder.field(STATE_FIELD, state);
}
if (detectorId != null) {
xContentBuilder.field(DETECTOR_ID_FIELD, detectorId);
}
if (taskProgress != null) {
xContentBuilder.field(TASK_PROGRESS_FIELD, taskProgress);
}
if (initProgress != null) {
xContentBuilder.field(INIT_PROGRESS_FIELD, initProgress);
}
if (currentPiece != null) {
xContentBuilder.field(CURRENT_PIECE_FIELD, currentPiece.toEpochMilli());
}
if (executionStartTime != null) {
xContentBuilder.field(EXECUTION_START_TIME_FIELD, executionStartTime.toEpochMilli());
}
if (executionEndTime != null) {
xContentBuilder.field(EXECUTION_END_TIME_FIELD, executionEndTime.toEpochMilli());
}
if (isLatest != null) {
xContentBuilder.field(IS_LATEST_FIELD, isLatest);
}
if (taskType != null) {
xContentBuilder.field(TASK_TYPE_FIELD, taskType);
}
if (checkpointId != null) {
xContentBuilder.field(CHECKPOINT_ID_FIELD, checkpointId);
}
if (coordinatingNode != null) {
xContentBuilder.field(COORDINATING_NODE_FIELD, coordinatingNode);
}
if (workerNode != null) {
xContentBuilder.field(WORKER_NODE_FIELD, workerNode);
}
if (detector != null) {
xContentBuilder.field(DETECTOR_FIELD, detector);
}
if (detectionDateRange != null) {
xContentBuilder.field(DETECTION_DATE_RANGE_FIELD, detectionDateRange);
}
if (entity != null) {
xContentBuilder.field(ENTITY_FIELD, entity);
}
if (parentTaskId != null) {
xContentBuilder.field(PARENT_TASK_ID_FIELD, parentTaskId);
}
if (estimatedMinutesLeft != null) {
xContentBuilder.field(ESTIMATED_MINUTES_LEFT_FIELD, estimatedMinutesLeft);
}
if (user != null) {
xContentBuilder.field(USER_FIELD, user);
}
return xContentBuilder.endObject();
}