Exemplo n.º 1
0
        public ImporterPresenter(
            IImporterView view,
            IDataSetToDataRepositoryMapper dataRepositoryMapper,
            IImporter importer,
            INanPresenter nanPresenter,
            IImporterDataPresenter importerDataPresenter,
            IImportConfirmationPresenter confirmationPresenter,
            IColumnMappingPresenter columnMappingPresenter,
            ISourceFilePresenter sourceFilePresenter,
            IDialogCreator dialogCreator,
            IPKMLPersistor pkmlPersistor) : base(view)
        {
            _importerDataPresenter  = importerDataPresenter;
            _confirmationPresenter  = confirmationPresenter;
            _columnMappingPresenter = columnMappingPresenter;
            _nanPresenter           = nanPresenter;
            _sourceFilePresenter    = sourceFilePresenter;
            _dataRepositoryMapper   = dataRepositoryMapper;
            _dataSource             = new DataSource(importer);
            _pkmlPersistor          = pkmlPersistor;
            _importer      = importer;
            _dialogCreator = dialogCreator;

            _sourceFilePresenter.Title                 = Captions.Importer.PleaseSelectDataFile;
            _sourceFilePresenter.Filter                = Captions.Importer.ImportFileFilter;
            _sourceFilePresenter.DirectoryKey          = Constants.DirectoryKey.OBSERVED_DATA;
            _sourceFilePresenter.OnSourceFileChanged  += (s, e) => SetDataSource(e.FileName);
            _sourceFilePresenter.CheckBeforeSelectFile = () =>
                                                         !_dataSource.DataSets.Any() || dialogCreator.MessageBoxYesNo(Captions.Importer.OpenFileConfirmation) == ViewResult.Yes;

            _view.AddColumnMappingControl(columnMappingPresenter.View);
            _view.AddSourceFileControl(sourceFilePresenter.View);
            _view.AddNanView(nanPresenter.View);
            _confirmationPresenter.OnImportData              += ImportData;
            _confirmationPresenter.OnDataSetSelected         += plotDataSet;
            _confirmationPresenter.OnNamingConventionChanged += (s, a) =>
            {
                _dataSource.SetNamingConvention(a.NamingConvention);
                _confirmationPresenter.SetDataSetNames(_dataSource.NamesFromConvention());
                _configuration.NamingConventions = a.NamingConvention;
            };
            _importerDataPresenter.OnImportSheets += loadSheetsFromDataPresenter;
            _nanPresenter.OnNaNSettingsChanged    += (s, a) =>
            {
                _columnMappingPresenter.ValidateMapping();
                _configuration.NanSettings = _nanPresenter.Settings;
            };
            _view.AddConfirmationView(_confirmationPresenter.View);
            _view.AddImporterView(_importerDataPresenter.View);
            AddSubPresenters(_importerDataPresenter, _confirmationPresenter, _columnMappingPresenter, _sourceFilePresenter);
            _importerDataPresenter.OnFormatChanged     += onFormatChanged;
            _importerDataPresenter.OnTabChanged        += onTabChanged;
            _importerDataPresenter.OnDataChanged       += onImporterDataChanged;
            _columnMappingPresenter.OnMissingMapping   += onMissingMapping;
            _columnMappingPresenter.OnMappingCompleted += onCompletedMapping;
            View.DisableConfirmationView();
        }
Exemplo n.º 2
0
 public ImporterPresenterForTest(
     IImporterView view,
     IDataSetToDataRepositoryMapper dataRepositoryMapper,
     IImporter importer,
     INanPresenter nanPresenter,
     IImporterDataPresenter importerDataPresenter,
     IImportConfirmationPresenter confirmationPresenter,
     IColumnMappingPresenter columnMappingPresenter,
     ISourceFilePresenter sourceFilePresenter,
     IDialogCreator dialogCreator,
     IPKMLPersistor pkmlPersistor,
     IDataSource dataSource
     ) : base(view, dataRepositoryMapper, importer, nanPresenter, importerDataPresenter, confirmationPresenter, columnMappingPresenter,
              sourceFilePresenter, dialogCreator, pkmlPersistor)
 {
     _dataSource = dataSource;
 }
Exemplo n.º 3
0
        public override void GlobalContext()
        {
            base.GlobalContext();
            _fakedTimeDimension          = A.Fake <IDimension>();
            _fakedConcentrationDimension = A.Fake <IDimension>();
            _fakedErrorDimension         = A.Fake <IDimension>();
            _fakedDimensionFactory       = A.Fake <IDimensionFactory>();
            _basicFormat   = A.Fake <DataSheet>();
            _container     = A.Fake <IContainer>();
            _dialogCreator = A.Fake <IDialogCreator>();
            var dataFormat = A.Fake <IDataFormat>();

            _columnInfos = new ColumnInfoCache
            {
                new ColumnInfo()
                {
                    DisplayName = "Time"
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration"
                },
                new ColumnInfo()
                {
                    DisplayName = "Error"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);

            A.CallTo(() => dataFormat.SetParameters(_basicFormat, _columnInfos, null)).Returns(1);
            A.CallTo(() => _container.ResolveAll <IDataFormat>()).Returns(new List <IDataFormat>()
            {
                dataFormat
            });
            _parser = A.Fake <IDataSourceFileParser>();
            _dataRepositoryMapper = A.Fake <IDataSetToDataRepositoryMapper>();
            A.CallTo(() => _container.Resolve <IDataSourceFileParser>()).Returns(_parser);
            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);
            sut = new OSPSuite.Infrastructure.Import.Services.Importer(_container, _parser, _dataRepositoryMapper, _fakedDimensionFactory);
        }
Exemplo n.º 4
0
        protected override void Context()
        {
            _dataImporterSettings = new DataImporterSettings();
            base.Context();
            _mapper = A.Fake <IDataSetToDataRepositoryMapper>();
            var cache   = new Cache <string, IDataSet>();
            var dataSet = new DataSet();

            dataSet.AddData(new List <ParsedDataSet>()
            {
                new ParsedDataSet(new List <string>(), A.Fake <DataSheet>(), new List <UnformattedRow>(), new Dictionary <ExtendedColumn, IList <SimulationPoint> >())
            });
            _dataSource = A.Fake <IDataSource>();
            A.CallTo(() => _dataSource.DataSets).Returns(cache);
            cache.Add("sheet1", dataSet);
            var dataRepository = new DataRepository {
                Name = "name"
            };

            dataRepository.ExtendedProperties.Add(new ExtendedProperty <string>()
            {
                Name = "Molecule", Value = "Molecule1"
            });
            dataRepository.ExtendedProperties.Add(new ExtendedProperty <string>()
            {
                Name = "Mol weight", Value = 22.0.ToString()
            });

            var dataColumn = new BaseGrid("Time", A.Fake <IDimension>());
            var dataInfo   = new DataInfo(ColumnOrigins.Undefined);

            dataColumn.DataInfo = dataInfo;
            dataRepository.Add(dataColumn);

            var moleculeDataColumn = new DataColumn("Measurement", A.Fake <IDimension>(), dataColumn);

            dataColumn.DataInfo = dataInfo;
            dataRepository.Add(moleculeDataColumn);
            A.CallTo(() => _mapper.ConvertImportDataSet(A <ImportedDataSet> .Ignored)).Returns(new DataSetToDataRepositoryMappingResult(dataRepository));

            var moleculeMetaDataCategory = createMetaDataCategory <string>("Molecule", isMandatory: true);

            moleculeMetaDataCategory.IsListOfValuesFixed = true;
            moleculeMetaDataCategory.DefaultValue        = "Molecule1";
            moleculeMetaDataCategory.ListOfValues.Add("Molecule1", 6.0.ToString());
            moleculeMetaDataCategory.ShouldListOfValuesBeIncluded = true;
            moleculeMetaDataCategory.SelectDefaultValue           = true;

            _metaDataCategories = new List <MetaDataCategory>()
            {
                moleculeMetaDataCategory,
                createMetaDataCategory <string>("Mol weight", isMandatory: false)
            };
            var dataFormat = A.Fake <IDataFormat>();

            A.CallTo(() => dataFormat.Parameters).Returns(new List <DataFormatParameter>());
            _dataSourceFile = A.Fake <IDataSourceFile>();
            A.CallTo(() => _dataSourceFile.Format).Returns(dataFormat);
            _importerDataPresenter = A.Fake <IImporterDataPresenter>();
            A.CallTo(() => _importerDataPresenter.SetDataSource(A <string> .Ignored)).Returns(_dataSourceFile);
            _importerView = A.Fake <IImporterView>();
            _importer     = A.Fake <IImporter>();
            _nanPresenter = A.Fake <INanPresenter>();
            _importConfirmationPresenter = A.Fake <IImportConfirmationPresenter>();
            _columnMappingPresenter      = A.Fake <IColumnMappingPresenter>();
            _sourceFilePresenter         = A.Fake <ISourceFilePresenter>();
            _dialogCreator = A.Fake <IDialogCreator>();
            _pkmlPeristor  = A.Fake <IPKMLPersistor>();

            sut = new ImporterPresenterForTest(
                _importerView,
                _mapper,
                _importer,
                _nanPresenter,
                _importerDataPresenter,
                _importConfirmationPresenter,
                _columnMappingPresenter,
                _sourceFilePresenter,
                _dialogCreator,
                _pkmlPeristor,
                _dataSource);
            _importerConfiguration = A.Fake <ImporterConfiguration>();
            sut.LoadConfiguration(_importerConfiguration, "");
            sut.SetSettings(_metaDataCategories, new ColumnInfoCache(), _dataImporterSettings);
        }
Exemplo n.º 5
0
        public override void GlobalContext()
        {
            base.GlobalContext();
            _fakedTimeDimension          = A.Fake <IDimension>();
            _fakedConcentrationDimension = A.Fake <IDimension>();
            _fakedErrorDimension         = A.Fake <IDimension>();
            _container             = A.Fake <IContainer>();
            _dialogCreator         = A.Fake <IDialogCreator>();
            _fakedDimensionFactory = A.Fake <IDimensionFactory>();
            var dataFormat = A.Fake <IDataFormat>();

            _columnInfos = new ColumnInfoCache()
            {
                new ColumnInfo()
                {
                    DisplayName = "Time"
                },
                new ColumnInfo()
                {
                    DisplayName = "Concentration"
                },
                new ColumnInfo()
                {
                    DisplayName = "Error"
                }
            };
            _metaDataCategories = new List <MetaDataCategory>()
            {
                new MetaDataCategory()
                {
                    Name = "Organ"
                },
                new MetaDataCategory()
                {
                    Name = "Compartment"
                },
                new MetaDataCategory()
                {
                    Name = "Species"
                },
                new MetaDataCategory()
                {
                    Name = "Dose"
                },
                new MetaDataCategory()
                {
                    Name = "Molecule"
                },
                new MetaDataCategory()
                {
                    Name = "Route"
                }
            };

            _columnInfos["Time"].SupportedDimensions.Add(_fakedTimeDimension);
            _columnInfos["Concentration"].SupportedDimensions.Add(_fakedConcentrationDimension);
            _columnInfos["Error"].SupportedDimensions.Add(_fakedErrorDimension);

            A.CallTo(() => _fakedTimeDimension.HasUnit("min")).Returns(true);
            A.CallTo(() => _fakedConcentrationDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _fakedErrorDimension.HasUnit("pmol/l")).Returns(true);
            A.CallTo(() => _container.ResolveAll <IDataFormat>()).Returns(new List <IDataFormat>()
            {
                new DataFormatHeadersWithUnits(), new DataFormatNonmem(), new MixColumnsDataFormat()
            });
            _parser = A.Fake <IDataSourceFileParser>();
            _dataRepositoryMapper = A.Fake <IDataSetToDataRepositoryMapper>();
            A.CallTo(() => _container.Resolve <IDataSourceFileParser>()).Returns(_parser);
            sut = new OSPSuite.Infrastructure.Import.Services.Importer(_container, _parser, _dataRepositoryMapper, _fakedDimensionFactory);
        }