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);
      }
    }
  }
private void transformTimeSeries(String metricName, AnomalyDetectionContext anomalyDetectionContext) {
   
    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));
      }
    }
   
    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);
      }
    }
  }
private void transformtimeseries(string metricname, anomalydetectioncontext anomalydetectioncontext) { 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)); } } 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); } } }