// Transform baseline time series
private void transformTimeSeries(String metricName, AnomalyDetectionContext anomalyDetectionContext) {
    // Transform the observed (current) time series
    if (anomalyDetectionContext.getTransformedCurrent(metricName) == null) {
      anomalyDetectionContext.setTransformedCurrent(metricName, anomalyDetectionContext.getCurrent(metricName));
    }
    List<TransformationFunction> currentTimeSeriesTransformationChain =
        getCurrentTimeSeriesTransformationChain();
    if (CollectionUtils.isNotEmpty(currentTimeSeriesTransformationChain)) {
      for (TransformationFunction tf : currentTimeSeriesTransformationChain) {
        anomalyDetectionContext
            .setTransformedCurrent(metricName, tf.transform(anomalyDetectionContext.getTransformedCurrent(metricName),
                anomalyDetectionContext));
      }
    }
    // Transform baseline time series
    if (anomalyDetectionContext.getTransformedBaselines(metricName) == null) {
      anomalyDetectionContext.setTransformedBaselines(metricName, anomalyDetectionContext.getBaselines(metricName));
    }
    List<TransformationFunction> baselineTimeSeriesTransformationChain =
        getBaselineTimeSeriesTransformationChain();
    if (CollectionUtils.isNotEmpty(anomalyDetectionContext.getTransformedBaselines(metricName))
        && CollectionUtils.isNotEmpty(baselineTimeSeriesTransformationChain)) {
      for (TransformationFunction tf : baselineTimeSeriesTransformationChain) {
        List<TimeSeries> transformedBaselines = new ArrayList<>();
        for (TimeSeries ts : anomalyDetectionContext.getTransformedBaselines(metricName)) {
          TimeSeries transformedTS = tf.transform(ts, anomalyDetectionContext);
          transformedBaselines.add(transformedTS);
        }
        anomalyDetectionContext.setTransformedBaselines(metricName, transformedBaselines);
      }
    }
  }
}
}
// Transform baseline time series
if (anomalyDetectionContext.getTransformedBaselines(metricName) == null) {
anomalyDetectionContext.setTransformedBaselines(metricName, anomalyDetectionContext.getBaselines(metricName));
}
List<TransformationFunction> currentTimeSeriesTransformationChain =
getCurrentTimeSeriesTransformationChain();
if (CollectionUtils.isNotEmpty(currentTimeSeriesTransformationChain)) {
for (TransformationFunction tf : currentTimeSeriesTransformationChain) {
anomalyDetectionContext
.setTransformedCurrent(metricName, tf.transform(anomalyDetectionContext.getTransformedCurrent(metricName),
anomalyDetectionContext));
}
}
// Transform baseline time series
if (anomalyDetectionContext.getTransformedBaselines(metricName) == null) {
anomalyDetectionContext.setTransformedBaselines(metricName, anomalyDetectionContext.getBaselines(metricName));
}
List<TransformationFunction> baselineTimeSeriesTransformationChain =
getBaselineTimeSeriesTransformationChain();
if (CollectionUtils.isNotEmpty(anomalyDetectionContext.getTransformedBaselines(metricName))
&& CollectionUtils.isNotEmpty(baselineTimeSeriesTransformationChain)) {
for (TransformationFunction tf : baselineTimeSeriesTransformationChain) {
List<TimeSeries> transformedBaselines = new ArrayList<>();
for (TimeSeries ts : anomalyDetectionContext.getTransformedBaselines(metricName)) {
private void transformTimeSeries(String metricName, AnomalyDetectionContext anomalyDetectionContext) {
// Transform the observed (current) time series
if (anomalyDetectionContext.getTransformedCurrent(metricName) == null) {
anomalyDetectionContext.setTransformedCurrent(metricName, anomalyDetectionContext.getCurrent(metricName));
}
List<TransformationFunction> currentTimeSeriesTransformationChain =
getCurrentTimeSeriesTransformationChain();
if (CollectionUtils.isNotEmpty(currentTimeSeriesTransformationChain)) {
for (TransformationFunction tf : currentTimeSeriesTransformationChain) {
anomalyDetectionContext
.setTransformedCurrent(metricName, tf.transform(anomalyDetectionContext.getTransformedCurrent(metricName),
anomalyDetectionContext));
}
}
// Transform baseline time series
if (anomalyDetectionContext.getTransformedBaselines(metricName) == null) {
anomalyDetectionContext.setTransformedBaselines(metricName, anomalyDetectionContext.getBaselines(metricName));
}
List<TransformationFunction> baselineTimeSeriesTransformationChain =
getBaselineTimeSeriesTransformationChain();
if (CollectionUtils.isNotEmpty(anomalyDetectionContext.getTransformedBaselines(metricName))
&& CollectionUtils.isNotEmpty(baselineTimeSeriesTransformationChain)) {
for (TransformationFunction tf : baselineTimeSeriesTransformationChain) {
List<TimeSeries> transformedBaselines = new ArrayList<>();
for (TimeSeries ts : anomalyDetectionContext.getTransformedBaselines(metricName)) {
TimeSeries transformedTS = tf.transform(ts, anomalyDetectionContext);
transformedBaselines.add(transformedTS);
}
anomalyDetectionContext.setTransformedBaselines(metricName, transformedBaselines);
}
}
}