public RegionService(IRegionRepository regionRepository, IRegionResolver regionResolver, IAggregateTileResolver tileResolver, ITileService tileService) { _regionRepository = regionRepository; _regionResolver = regionResolver; _tileResolver = tileResolver; _tileService = tileService; }
public RegionBuilder(IRegionService regionService, IRiverBuilder riverBuilder, IList<IResourceBuilder> resourceBuilders, IRegionResolver regionResolver, IAggregateTileResolver tileResolver, ITileService tileService) { _regionService = regionService; _regionResolver = regionResolver; _tileResolver = tileResolver; _tileService = tileService; _riverBuilder = riverBuilder; _resourceBuilders = resourceBuilders; }
public void CheckRegions(IRegionResolver regionResolver) { var unknownRegions = new List<string>(); while (Reader.ReadNextRecord()) { string regionName = Reader[0]; if (!regionResolver.Contains(regionName)) { if (!unknownRegions.Contains(regionName)) unknownRegions.Add(regionName); } } if (unknownRegions.Count > 0) throw new InvalidDataException("Unknown regions: " + String.Join(",", unknownRegions)); }
public IEnumerable<PollProtocol> LoadProtocols(IRegionResolver regionResolver) { while (Reader.ReadNextRecord()) { string regionName = Reader[ColumnIndexRegion]; Int32 commision; Region region = regionResolver.GetOrCreate(regionName); if (!Int32.TryParse(Reader[ColumnIndexComission], out commision)) throw new InvalidDataException("Can't parse as Int32: " + Reader[ColumnIndexComission] + ". Row #" + Reader.CurrentRecordIndex); var results = new int[ResultColumnsCount]; for (int i = 0; i < ResultColumnsCount; i++) { results[i] = Int32.Parse(Reader[i + FirstResultColumnIndex]); } // Images List<PollProtocolImage> images = null; if (FirstImageUriColumnIndex > -1) { images = new List<PollProtocolImage>(); Uri uri; for (int i = FirstImageUriColumnIndex; i < Reader.FieldCount; i++) { string value = Reader[i]; if (string.IsNullOrWhiteSpace(value)) break; if (!Uri.TryCreate(value, UriKind.Absolute, out uri)) throw new InvalidDataException("Can't parse as Uri: " + value + ". Row #" + Reader.CurrentRecordIndex); images.Add(new PollProtocolImage { Uri = uri.ToString() }); } } var result = new PollProtocol { Region = region, Comission = commision, Results = results, Images = images }; yield return result; } }
public SimulationExplorerPresenter( ISimulationExplorerView view, ITreeNodeFactory treeNodeFactory, ITreeNodeContextMenuFactory treeNodeContextMenuFactory, IMultipleTreeNodeContextMenuFactory multipleTreeNodeContextMenuFactory, IBuildingBlockIconRetriever buildingBlockIconRetriever, IRegionResolver regionResolver, IBuildingBlockTask buildingBlockTask, IBuildingBlockInProjectManager buildingBlockInProjectManager, IToolTipPartCreator toolTipPartCreator, IProjectRetriever projectRetriever, IClassificationPresenter classificationPresenter, IParameterAnalysablesInExplorerPresenter parameterAnalysablesInExplorerPresenter, IObservedDataInSimulationManager observedDataInSimulationManager, ISimulationComparisonTask simulationComparisonTask) : base(view, treeNodeFactory, treeNodeContextMenuFactory, multipleTreeNodeContextMenuFactory, buildingBlockIconRetriever, regionResolver, buildingBlockTask, RegionNames.SimulationExplorer, projectRetriever, classificationPresenter, toolTipPartCreator) { _buildingBlockInProjectManager = buildingBlockInProjectManager; _parameterAnalysablesInExplorerPresenter = parameterAnalysablesInExplorerPresenter; _observedDataInSimulationManager = observedDataInSimulationManager; _simulationComparisonTask = simulationComparisonTask; _parameterAnalysablesInExplorerPresenter.InitializeWith(this, classificationPresenter); }
protected override void Context() { _view = A.Fake <IBuildingBlockExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _regionResolver = A.Fake <IRegionResolver>(); _region = A.Fake <IRegion>(); A.CallTo(() => _regionResolver.RegionWithName(RegionNames.BuildingBlockExplorer)).Returns(_region); _project = new PKSimProject(); var compound = new Compound().WithName("compound"); _individual = new Individual().WithName("individual"); _individual.OriginData = new OriginData { Species = new Species() }; _project.AddBuildingBlock(_individual); _project.AddBuildingBlock(compound); _observedDataInExplorerPresenter = A.Fake <IObservedDataInExplorerPresenter>(); _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); sut = new BuildingBlockExplorerPresenter(_view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _toolTipCreator, _projectRetriever, _classificationPresenter, _observedDataInExplorerPresenter); _compoundFolderNode = new RootNode(PKSimRootNodeTypes.CompoundFolder); _individualFolderNode = new RootNode(PKSimRootNodeTypes.IndividualFolder); _formulationFolderNode = new RootNode(PKSimRootNodeTypes.FormulationFolder); _protocolFolderNode = new RootNode(PKSimRootNodeTypes.ProtocolFolder); _observersFolderNode = new RootNode(PKSimRootNodeTypes.ObserverSetFolder); _populationFolderNode = new RootNode(PKSimRootNodeTypes.PopulationFolder); _eventRootNode = new RootNode(PKSimRootNodeTypes.EventFolder); _simulationNode = new SimulationNode(new ClassifiableSimulation { Subject = new IndividualSimulation { Id = "1" } }); _compoundNode = new ObjectWithIdAndNameNode <Compound>(compound); _individualNode = new ObjectWithIdAndNameNode <Individual>(_individual); _observationRootNode = new RootNode(RootNodeTypes.ObservedDataFolder); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.CompoundFolder)).Returns(_compoundFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.IndividualFolder)).Returns(_individualFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ProtocolFolder)).Returns(_protocolFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.ObserverSetFolder)).Returns(_observersFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.FormulationFolder)).Returns(_formulationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.PopulationFolder)).Returns(_populationFolderNode); A.CallTo(() => _treeNodeFactory.CreateFor(RootNodeTypes.ObservedDataFolder)).Returns(_observationRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(PKSimRootNodeTypes.EventFolder)).Returns(_eventRootNode); A.CallTo(() => _treeNodeFactory.CreateFor(_individual)).Returns(_individualNode); A.CallTo(() => _treeNodeFactory.CreateFor(compound)).Returns(_compoundNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.CompoundFolder.Id)).Returns(_compoundFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.IndividualFolder.Id)).Returns(_individualFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ProtocolFolder.Id)).Returns(_protocolFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.ObserverSetFolder.Id)).Returns(_observersFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.FormulationFolder.Id)).Returns(_formulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.PopulationFolder.Id)).Returns(_populationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ObservedDataFolder.Id)).Returns(_observationRootNode); A.CallTo(() => _view.TreeView.NodeById(PKSimRootNodeTypes.EventFolder.Id)).Returns(_eventRootNode); A.CallTo(() => _view.AddNode(A <ITreeNode> ._)).ReturnsLazily(s => s.Arguments[0].DowncastTo <ITreeNode>()); }
protected ExplorerPresenter(TView view, ITreeNodeFactory treeNodeFactory, ITreeNodeContextMenuFactory treeNodeContextMenuFactory, IMultipleTreeNodeContextMenuFactory multipleTreeNodeContextMenuFactory, IBuildingBlockIconRetriever buildingBlockIconRetriever, IRegionResolver regionResolver, IBuildingBlockTask buildingBlockTask, RegionName regionName, IProjectRetriever projectRetriever, IClassificationPresenter classificationPresenter, IToolTipPartCreator toolTipPartCreator) : base(view, regionResolver, classificationPresenter, toolTipPartCreator, regionName, projectRetriever) { _treeNodeFactory = treeNodeFactory; _treeNodeContextMenuFactory = treeNodeContextMenuFactory; _multipleTreeNodeContextMenuFactory = multipleTreeNodeContextMenuFactory; _buildingBlockIconRetriever = buildingBlockIconRetriever; _buildingBlockTask = buildingBlockTask; }
public HistoryPresenter(IMoBiContext context, IHistoryBrowserPresenter historyBrowserPresenter, IRegionResolver regionResolver, IApplicationConfiguration applicationConfiguration, IDisplayNameProvider displayNameProvider) { _context = context; _historyBrowserPresenter = historyBrowserPresenter; _regionResolver = regionResolver; _applicationConfiguration = applicationConfiguration; _displayNameProvider = displayNameProvider; _historyBrowserPresenter.EnableHistoryPruning = false; }
public JournalDiagramMainPresenter(OSPSuite.Presentation.Views.Journal.IJournalDiagramMainView view, IJournalDiagramPresenter journaliDiagramPresenter, IRegionResolver regionResolver) : base(view, journaliDiagramPresenter, regionResolver, RegionNames.JournalDiagram) { }
public MainComparisonPresenter(IMainComparisonView view, IRegionResolver regionResolver, IComparisonPresenter comparisonPresenter, IComparerSettingsPresenter comparerSettingsPresenter, IPresentationUserSettings presentationUserSettings, IDialogCreator dialogCreator, IExportDataTableToExcelTask exportToExcelTask, IExecutionContext executionContext) : base(view, regionResolver, comparisonPresenter, comparerSettingsPresenter, presentationUserSettings, dialogCreator, exportToExcelTask, executionContext, RegionNames.Comparison) { }
public HistoryPresenter(IHistoryBrowserPresenter historyBrowserPresenter, IWorkspace workspace, IRegionResolver regionResolver, IExecutionContext executionContext, IApplicationConfiguration applicationConfiguration) { _historyBrowserPresenter = historyBrowserPresenter; _workspace = workspace; _executionContext = executionContext; _applicationConfiguration = applicationConfiguration; _initialized = false; _region = regionResolver.RegionWithName(RegionNames.History); _region.Add(_historyBrowserPresenter.View); }
public BuildingBlockExplorerPresenter(IBuildingBlockExplorerView view, ITreeNodeFactory treeNodeFactory, ITreeNodeContextMenuFactory treeNodeContextMenuFactory, IMultipleTreeNodeContextMenuFactory multipleTreeNodeContextMenuFactory, IBuildingBlockIconRetriever buildingBlockIconRetriever, IRegionResolver regionResolver, IBuildingBlockTask buildingBlockTask, IToolTipPartCreator toolTipPartCreator, IProjectRetriever projectRetriever, IClassificationPresenter classificationPresenter, IObservedDataInExplorerPresenter observedDataInExplorerPresenter) : base(view, treeNodeFactory, treeNodeContextMenuFactory, multipleTreeNodeContextMenuFactory, buildingBlockIconRetriever, regionResolver, buildingBlockTask, RegionNames.BuildingBlockExplorer, projectRetriever, classificationPresenter, toolTipPartCreator) { _observedDataInExplorerPresenter = observedDataInExplorerPresenter; _observedDataInExplorerPresenter.InitializeWith(this, classificationPresenter, RootNodeTypes.ObservedDataFolder); }
public ExplorerForTestPresenter(IExplorerForTestView view, IRegionResolver regionResolver, IClassificationPresenter classificationPresenter, IToolTipPartCreator toolTipPartCreator, IProjectRetriever projectRetriever) : base(view, regionResolver, classificationPresenter, toolTipPartCreator, RegionNames.Explorer, projectRetriever) { }
public IEnumerable<PollProtocol> LoadProtocols(IRegionResolver regionResolver) { var htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(m_pageContent); var reUikNumber = new Regex(@"\d+", RegexOptions.Compiled | RegexOptions.Multiline); foreach (HtmlNode headUik in htmlDoc.DocumentNode.SelectNodes("//h3[@class='uik']")) { var regionNode = headUik.SelectSingleNode("preceding-sibling::h2[@class='oblast']"); var uikText = headUik.InnerText; if (regionNode == null) { m_logger.LogError("Can't find region node in the html"); } else { var match = reUikNumber.Match(uikText); if (!match.Success) { m_logger.LogError("Can't parse comission number: " + uikText); continue; } int comissionNum; if (!Int32.TryParse(match.Value, out comissionNum)) { m_logger.LogError("Can't parse parse comission number as integer: " + match.Value); continue; } string regionName = regionNode.InnerText; Region region = regionResolver.GetOrCreate(regionName); // Results var tableResults = headUik.SelectSingleNode("following-sibling::table[@class='observers_data']"); if (tableResults == null) { m_logger.LogError(String.Format("{0}/{1}: Can't find table with protocols results (table[@class='observers_data'])", regionName, comissionNum)); continue; } var trAltResults = tableResults.SelectSingleNode("descendant::tr[@class='obs']"); if (trAltResults == null) { m_logger.LogError(String.Format("{0}/{1}: Can't find table row with alternative protocol results (tr[@class='obs'])", regionName, comissionNum)); continue; } var tdResults = trAltResults.SelectNodes("td"); var results = new int[25]; if (tdResults.Count != 26) { m_logger.LogError(String.Format("{0}/{1}: Number of columns in row with protocol result doesn't equal expected value (26), but equals to {2}", regionName, comissionNum, tdResults.Count)); continue; } bool needBreak = false; for (int i = 1; i < 26; i++) { string votesRaw = tdResults[i].InnerText; int votes; if (!Int32.TryParse(votesRaw, out votes)) { m_logger.LogError(String.Format("{0}/{1}: Can't parse votes count as integer: {2}", regionName, comissionNum, tdResults.Count)); needBreak = true; break; } results[i - 1] = votes; } if (needBreak) continue; // Images: var imagesNode = headUik.SelectSingleNode("following-sibling::div[@class='photo_names']"); if (imagesNode == null) { m_logger.LogError(String.Format("{0}/{1}: Can't find div with protocol images (div[@class='photo_names'])", regionName, comissionNum)); continue; } var images = new List<PollProtocolImage>(); var imageAnchorNodes = imagesNode.SelectNodes("descendant::a"); if (imageAnchorNodes == null || imageAnchorNodes.Count == 0) m_logger.LogWarning(String.Format("{0}/{1}: Can't find hyperlinks to protocol images (a)", regionName, comissionNum)); else { foreach (HtmlNode anchorNode in imageAnchorNodes) { string uri = anchorNode.GetAttributeValue("href", ""); // remove uri parameters (everything after "?") var idx = uri.IndexOf("?"); if (idx > -1) uri = uri.Substring(0, idx); string filePath; byte[] imageBytes = null; if (m_imageFilesMap.TryGetValue(uri, out filePath)) imageBytes = File.ReadAllBytes(filePath); var protocolImage = new PollProtocolImage { Uri = uri, Image = imageBytes }; images.Add(protocolImage); } } var protocol = new PollProtocol { Region = region, Comission = comissionNum, Images = images, Results = results }; yield return protocol; } } }
protected override void Context() { _buildingBlockIconRetriever = A.Fake <IBuildingBlockIconRetriever>(); _view = A.Fake <ISimulationExplorerView>(); A.CallTo(() => _view.TreeView).Returns(A.Fake <IUxTreeView>()); _treeNodeFactory = A.Fake <ITreeNodeFactory>(); _contextMenuFactory = A.Fake <ITreeNodeContextMenuFactory>(); _regionResolver = A.Fake <IRegionResolver>(); _buildingBlockInSimulationManager = A.Fake <IBuildingBlockInSimulationManager>(); _buildingBlockTask = A.Fake <IBuildingBlockTask>(); _toolTipNodeCreator = A.Fake <IToolTipPartCreator>(); _projectRetriever = A.Fake <IProjectRetriever>(); _multipleTreeNodeContextMenuFactory = A.Fake <IMultipleTreeNodeContextMenuFactory>(); _parameterAnalysablesInExplorerPresenter = A.Fake <IParameterAnalysablesInExplorerPresenter>(); _simulationComparisonTask = A.Fake <ISimulationComparisonTask>(); _simulationFolderNode = new RootNode(RootNodeTypes.SimulationFolder); _comparisonFolderNode = new RootNode(RootNodeTypes.ComparisonFolder); _project = new PKSimProject(); _usedObservedData = new UsedObservedData { Id = "UsedData" }; _simulation = new IndividualSimulation().WithName("individualSimulation").WithId("individualSimulation"); _populationSimulation = new PopulationSimulation().WithName("populationSimulation").WithId("populationSimulation"); _importedSimulaton = A.Fake <Simulation>().WithName("ImportedSimulation").WithId("ImportedSimulation"); A.CallTo(() => _importedSimulaton.IsImported).Returns(true); _simulation.Properties = new SimulationProperties(); _simulation.ModelProperties = new ModelProperties(); _simulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _populationSimulation.Properties = new SimulationProperties(); _populationSimulation.ModelProperties = new ModelProperties(); _populationSimulation.ModelConfiguration = A.Fake <ModelConfiguration>(); _classificationPresenter = A.Fake <IClassificationPresenter>(); _project.AddBuildingBlock(_simulation); _project.AddBuildingBlock(_populationSimulation); var classifiableIndividualSimulation = new ClassifiableSimulation { Subject = _simulation }; var classfiablePopulationSimulation = new ClassifiableSimulation { Subject = _populationSimulation }; var classifiableImportSimulation = new ClassifiableSimulation { Subject = _importedSimulaton }; _project.AddClassifiable(classifiableIndividualSimulation); _project.AddClassifiable(classfiablePopulationSimulation); _individualSimulationNode = new SimulationNode(classifiableIndividualSimulation); _populationSimulationNode = new SimulationNode(classfiablePopulationSimulation); _importedSimulationNode = new SimulationNode(classifiableImportSimulation); _usedObservedDataNode = A.Fake <ITreeNode>(); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableIndividualSimulation)).Returns(_individualSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classfiablePopulationSimulation)).Returns(_populationSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableImportSimulation)).Returns(_importedSimulationNode); A.CallTo(() => _treeNodeFactory.CreateFor(_usedObservedData)).Returns(_usedObservedDataNode); _project.AddBuildingBlock(_importedSimulaton); var simulationComparison = A.Fake <ISimulationComparison>().WithId("SimComp_Id"); var classifiableComparison = new ClassifiableComparison { Subject = simulationComparison }; _comparisonNode = new ComparisonNode(classifiableComparison); _project.AddSimulationComparison(simulationComparison); A.CallTo(() => _treeNodeFactory.CreateFor(classifiableComparison)).Returns(_comparisonNode); _usedCompoundBuildingBlock = new UsedBuildingBlock("toto", PKSimBuildingBlockType.Compound) { Id = "usedBB" }; _simulation.AddUsedBuildingBlock(_usedCompoundBuildingBlock); _simulation.AddUsedObservedData(_usedObservedData); _project.AddClassifiable(classifiableComparison); _templageCompoundBuildingBlock = A.Fake <IPKSimBuildingBlock>(); _usedBuildingBlockNode = new UsedBuildingBlockInSimulationNode(_simulation, _usedCompoundBuildingBlock, _templageCompoundBuildingBlock); A.CallTo(() => _treeNodeFactory.CreateFor(_simulation, _usedCompoundBuildingBlock)).Returns(_usedBuildingBlockNode); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_simulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_populationSimulation)).Returns(ApplicationIcons.SimulationGreen); A.CallTo(() => _buildingBlockIconRetriever.IconFor(_usedCompoundBuildingBlock)).Returns(ApplicationIcons.CompoundRed); A.CallTo(() => _view.TreeView.NodeById(_simulation.Id)).Returns(_individualSimulationNode); A.CallTo(() => _view.TreeView.NodeById(_usedCompoundBuildingBlock.Id)).Returns(_usedBuildingBlockNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.SimulationFolder.Id)).Returns(_simulationFolderNode); A.CallTo(() => _view.TreeView.NodeById(RootNodeTypes.ComparisonFolder.Id)).Returns(_comparisonFolderNode); _observedDataInSimulationManager = A.Fake <IObservedDataInSimulationManager>(); sut = new SimulationExplorerPresenter( _view, _treeNodeFactory, _contextMenuFactory, _multipleTreeNodeContextMenuFactory, _buildingBlockIconRetriever, _regionResolver, _buildingBlockTask, _buildingBlockInSimulationManager, _toolTipNodeCreator, _projectRetriever, _classificationPresenter, _parameterAnalysablesInExplorerPresenter, _observedDataInSimulationManager, _simulationComparisonTask); A.CallTo(() => _projectRetriever.CurrentProject).Returns(_project); }
public JournalPresenter(IJournalView view, IRegionResolver regionResolver, IJournalPageToJournalPageDTOMapper mapper, IJournalTask journalTask, IViewItemContextMenuFactory viewItemContextMenuFactory, IJournalRetriever journalRetriever, IJournalPagePreviewPresenter previewPresenter, IJournalSearchPresenter searchPresenter) : base(view, regionResolver, mapper, journalTask, viewItemContextMenuFactory, journalRetriever, previewPresenter, searchPresenter, RegionNames.Journal) { }
public MainComparisonPresenterForSpecs(IMainComparisonView view, IRegionResolver regionResolver, IComparisonPresenter comparisonPresenter, IComparerSettingsPresenter comparerSettingsPresenter, IPresentationUserSettings presentationUserSettings, IDialogCreator dialogCreator, IExportDataTableToExcelTask exportToExcelTask, IOSPSuiteExecutionContext executionContext) : base(view, regionResolver, comparisonPresenter, comparerSettingsPresenter, presentationUserSettings, dialogCreator, exportToExcelTask, executionContext, new RegionName("A", "A", ApplicationIcons.Comparison)) { }
public RegionService(IRegionResolver <TRegion, TFocus> resolver) { this.Resolver = resolver; }