in src/main/java/org/opensearch/ad/model/ADTask.java [458:609]
public static ADTask parse(XContentParser parser, String taskId) throws IOException {
Instant lastUpdateTime = null;
String startedBy = null;
String stoppedBy = null;
String error = null;
String state = null;
String detectorId = null;
Float taskProgress = null;
Float initProgress = null;
Instant currentPiece = null;
Instant executionStartTime = null;
Instant executionEndTime = null;
Boolean isLatest = null;
String taskType = null;
String checkpointId = null;
AnomalyDetector detector = null;
String parsedTaskId = taskId;
String coordinatingNode = null;
String workerNode = null;
DetectionDateRange detectionDateRange = null;
Entity entity = null;
String parentTaskId = null;
Integer estimatedMinutesLeft = null;
User user = null;
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.currentToken(), parser);
while (parser.nextToken() != XContentParser.Token.END_OBJECT) {
String fieldName = parser.currentName();
parser.nextToken();
switch (fieldName) {
case LAST_UPDATE_TIME_FIELD:
lastUpdateTime = ParseUtils.toInstant(parser);
break;
case STARTED_BY_FIELD:
startedBy = parser.text();
break;
case STOPPED_BY_FIELD:
stoppedBy = parser.text();
break;
case ERROR_FIELD:
error = parser.text();
break;
case STATE_FIELD:
state = parser.text();
break;
case DETECTOR_ID_FIELD:
detectorId = parser.text();
break;
case TASK_PROGRESS_FIELD:
taskProgress = parser.floatValue();
break;
case INIT_PROGRESS_FIELD:
initProgress = parser.floatValue();
break;
case CURRENT_PIECE_FIELD:
currentPiece = ParseUtils.toInstant(parser);
break;
case EXECUTION_START_TIME_FIELD:
executionStartTime = ParseUtils.toInstant(parser);
break;
case EXECUTION_END_TIME_FIELD:
executionEndTime = ParseUtils.toInstant(parser);
break;
case IS_LATEST_FIELD:
isLatest = parser.booleanValue();
break;
case TASK_TYPE_FIELD:
taskType = parser.text();
break;
case CHECKPOINT_ID_FIELD:
checkpointId = parser.text();
break;
case DETECTOR_FIELD:
detector = AnomalyDetector.parse(parser);
break;
case TASK_ID_FIELD:
parsedTaskId = parser.text();
break;
case COORDINATING_NODE_FIELD:
coordinatingNode = parser.text();
break;
case WORKER_NODE_FIELD:
workerNode = parser.text();
break;
case DETECTION_DATE_RANGE_FIELD:
detectionDateRange = DetectionDateRange.parse(parser);
break;
case ENTITY_FIELD:
entity = Entity.parse(parser);
break;
case PARENT_TASK_ID_FIELD:
parentTaskId = parser.text();
break;
case ESTIMATED_MINUTES_LEFT_FIELD:
estimatedMinutesLeft = parser.intValue();
break;
case USER_FIELD:
user = User.parse(parser);
break;
default:
parser.skipChildren();
break;
}
}
AnomalyDetector anomalyDetector = detector == null
? null
: new AnomalyDetector(
detectorId,
detector.getVersion(),
detector.getName(),
detector.getDescription(),
detector.getTimeField(),
detector.getIndices(),
detector.getFeatureAttributes(),
detector.getFilterQuery(),
detector.getDetectionInterval(),
detector.getWindowDelay(),
detector.getShingleSize(),
detector.getUiMetadata(),
detector.getSchemaVersion(),
detector.getLastUpdateTime(),
detector.getCategoryField(),
detector.getUser(),
detector.getResultIndex()
);
return new Builder()
.taskId(parsedTaskId)
.lastUpdateTime(lastUpdateTime)
.startedBy(startedBy)
.stoppedBy(stoppedBy)
.error(error)
.state(state)
.detectorId(detectorId)
.taskProgress(taskProgress)
.initProgress(initProgress)
.currentPiece(currentPiece)
.executionStartTime(executionStartTime)
.executionEndTime(executionEndTime)
.isLatest(isLatest)
.taskType(taskType)
.checkpointId(checkpointId)
.coordinatingNode(coordinatingNode)
.workerNode(workerNode)
.detector(anomalyDetector)
.detectionDateRange(detectionDateRange)
.entity(entity)
.parentTaskId(parentTaskId)
.estimatedMinutesLeft(estimatedMinutesLeft)
.user(user)
.build();
}