Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/14 15:18:41 (10 years ago)
Author:
pfleck
Message:
  • Implemented handling of transformation error messages.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/PreprocessingTransformator.cs

    r10814 r10819  
    3333    }
    3434
    35     public bool ApplyTransformations(IEnumerable<ITransformation> transformations) {
    36       bool success = true;
     35    public bool ApplyTransformations(IEnumerable<ITransformation> transformations, out string errorMsg) {
     36      bool success;
    3737
    38       preprocessingData.InTransaction(() => {
     38      preprocessingData.BeginTransaction(DataPreprocessingChangedEventType.Transformation);
     39      try {
    3940        var doubleTransformations = transformations.OfType<Transformation<double>>().ToList();
    40         ApplyDoubleTranformations(doubleTransformations, out success);
    41       }, DataPreprocessingChangedEventType.Transformation);
    42 
    43       if (!success) {
    44         preprocessingData.Undo();
     41        ApplyDoubleTranformations(doubleTransformations, out success, out errorMsg);
     42      } finally {
     43        preprocessingData.EndTransaction();
     44        //if (!success)
     45        //preprocessingData.Undo();
    4546      }
    4647
     
    4849    }
    4950
    50     private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success) {
     51    private void ApplyDoubleTranformations(IEnumerable<Transformation<double>> transformations, out bool success, out string errorMsg) {
     52      errorMsg = string.Empty;
     53      success = true;
    5154      foreach (var transformation in transformations) {
    5255        int colIndex = preprocessingData.GetColumnIndex(transformation.Column);
    5356
    5457        var originalData = preprocessingData.GetValues<double>(colIndex);
    55         var transformedData = ApplyDoubleTransformation(transformation, originalData, out success);
    56         if (!success) return;
    57 
     58        string errorMsgPart;
     59        bool successPart;
     60        var transformedData = ApplyDoubleTransformation(transformation, originalData, out successPart, out errorMsgPart);
     61        errorMsg += errorMsgPart + Environment.NewLine;
     62        //if (!success) return;
     63        if (!successPart) success = false;
    5864        preprocessingData.SetValues(colIndex, transformedData.ToList());
    5965        preprocessingData.Transformations.Add(transformation);
    6066      }
    61       success = true;
     67
    6268    }
    6369
    64     private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success) {
    65       string errorMsg;
    66       if (transformation.Check(data, out errorMsg)) {
    67         success = true;
    68         return transformation.Apply(data);
    69       }
    70       throw new NotImplementedException("Display Check Result");
     70    private IEnumerable<double> ApplyDoubleTransformation(Transformation<double> transformation, IEnumerable<double> data, out bool success, out string errorMsg) {
     71      success = transformation.Check(data, out errorMsg);
     72      return transformation.Apply(data);
    7173    }
    7274  }
Note: See TracChangeset for help on using the changeset viewer.