From e71b5639de042976e4a4b2a24856a37751bfa4c6 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Tue, 21 Nov 2017 13:57:41 +0000 Subject: [PATCH] [ML] Rename id to forecast_id in forecast API response (elastic/x-pack-elasticsearch#3074) Original commit: elastic/x-pack-elasticsearch@c05d9fc6020ffd36e0a567f8486b1c34ab579453 --- .../xpack/ml/action/ForecastJobAction.java | 38 +++++++++++-------- .../autodetect/params/ForecastParams.java | 16 ++++---- .../writer/ControlMsgToProcessWriter.java | 2 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/ForecastJobAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/ForecastJobAction.java index b9b99f30daf..2fd0a52ae03 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/ForecastJobAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/ForecastJobAction.java @@ -29,6 +29,7 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.job.process.autodetect.params.ForecastParams; +import org.elasticsearch.xpack.ml.job.results.Forecast; import java.io.IOException; import java.util.Objects; @@ -157,56 +158,64 @@ public class ForecastJobAction extends Action { if (e == null) { - listener.onResponse(new Response(true, params.getId())); + listener.onResponse(new Response(true, params.getForecastId())); } else { listener.onFailure(e); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParams.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParams.java index 3e50d618e43..7c2ea46b62d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParams.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/params/ForecastParams.java @@ -18,10 +18,10 @@ public class ForecastParams { private final long endTime; private final long duration; - private final long id; + private final long forecastId; - private ForecastParams(long id, long endTime, long duration) { - this.id = id; + private ForecastParams(long forecastId, long endTime, long duration) { + this.forecastId = forecastId; this.endTime = endTime; this.duration = duration; } @@ -47,13 +47,13 @@ public class ForecastParams { * * @return The forecast Id */ - public long getId() { - return id; + public long getForecastId() { + return forecastId; } @Override public int hashCode() { - return Objects.hash(id, endTime, duration); + return Objects.hash(forecastId, endTime, duration); } @Override @@ -65,7 +65,9 @@ public class ForecastParams { return false; } ForecastParams other = (ForecastParams) obj; - return Objects.equals(id, other.id) && Objects.equals(endTime, other.endTime) && Objects.equals(duration, other.duration); + return Objects.equals(forecastId, other.forecastId) + && Objects.equals(endTime, other.endTime) + && Objects.equals(duration, other.duration); } public static Builder builder() { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java index 18c3303fd59..0b161b977b7 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/writer/ControlMsgToProcessWriter.java @@ -153,7 +153,7 @@ public class ControlMsgToProcessWriter { public void writeForecastMessage(ForecastParams params) throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder() .startObject() - .field("forecast_id", params.getId()); + .field("forecast_id", params.getForecastId()); if (params.getEndTime() != 0) { builder.field("end_time", params.getEndTime());