Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/14 15:18:41 (11 years ago)
Author:
pfleck
Message:
  • Implemented handling of transformation error messages.
Location:
branches/DataPreprocessing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/TransformationView.cs

    r10814 r10819  
    2222using System;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Data;
    2524using HeuristicLab.MainForm;
    2625using HeuristicLab.MainForm.WindowsForms;
     
    5453
    5554      var transformator = new PreprocessingTransformator(Content.Data);
    56       bool success = transformator.ApplyTransformations(transformations);
     55      string errorMsg;
     56      bool success = transformator.ApplyTransformations(transformations, out errorMsg);
    5757      if (success) {
    58         //foreach (var transformation in transformations)
    59         //  Content.CheckedTransformationCollection.SetItemCheckedState(transformation, false);
    6058        Content.CheckedTransformationCollection.Clear();
    6159        MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     60      } else {
     61        MessageBox.Show(this,
     62          "Error in Transformation.\nValue is copied when transformion of cell failed.\n" + errorMsg,
     63          "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    6264      }
     65
    6366    }
    6467  }
  • 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.