private void AddChildren(FrozenExtractionConfigurationsNode frozenExtractionConfigurationsNode, DescendancyList descendancy) { HashSet <object> children = new HashSet <object>(); //Add ExtractionConfigurations which are not released (frozen) var configs = ExtractionConfigurations.Where(c => c.Project_ID == frozenExtractionConfigurationsNode.Project.ID).ToArray(); foreach (ExtractionConfiguration config in configs.Where(c => c.IsReleased)) { AddChildren(config, descendancy.Add(config)); children.Add(config); } AddToDictionaries(children, descendancy); }
/// <summary> /// Deletes the dataset, this will make the <see cref="ICatalogue"/> non extractable. This operation fails if /// the dataset is part of any <see cref="ExtractionConfigurations"/>. /// </summary> public override void DeleteInDatabase() { try { Repository.DeleteFromDatabase(this); } catch (Exception e) { if (e.Message.Contains("FK_SelectedDataSets_ExtractableDataSet")) { throw new Exception("Cannot delete " + this + " because it is in use by the following configurations :" + Environment.NewLine + string.Join(Environment.NewLine, ExtractionConfigurations.Select(c => c.Name + "(" + c.Project + ")")), e); } throw; } }
private void AddChildren(ExtractionConfigurationsNode extractionConfigurationsNode, DescendancyList descendancy) { HashSet <object> children = new HashSet <object>(); var frozenConfigurationsNode = new FrozenExtractionConfigurationsNode(extractionConfigurationsNode.Project); children.Add(frozenConfigurationsNode); var configs = ExtractionConfigurations.Where(c => c.Project_ID == extractionConfigurationsNode.Project.ID).ToArray(); foreach (ExtractionConfiguration config in configs) { AddChildren(config, descendancy.Add(config)); children.Add(config); } AddToDictionaries(children, descendancy); }
private void AddChildren(ExtractionConfigurationsNode extractionConfigurationsNode, DescendancyList descendancy) { HashSet <object> children = new HashSet <object>(); //Create a frozen extraction configurations folder as a subfolder of each ExtractionConfigurationsNode var frozenConfigurationsNode = new FrozenExtractionConfigurationsNode(extractionConfigurationsNode.Project); //Make the frozen folder appear under the extractionConfigurationsNode children.Add(frozenConfigurationsNode); //Add children to the frozen folder AddChildren(frozenConfigurationsNode, descendancy.Add(frozenConfigurationsNode)); //Add ExtractionConfigurations which are not released (frozen) var configs = ExtractionConfigurations.Where(c => c.Project_ID == extractionConfigurationsNode.Project.ID).ToArray(); foreach (ExtractionConfiguration config in configs.Where(c => !c.IsReleased)) { AddChildren(config, descendancy.Add(config)); children.Add(config); } AddToDictionaries(children, descendancy); }
public DataExportChildProvider(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IChildProvider[] pluginChildProviders, ICheckNotifier errorsCheckNotifier, DataExportChildProvider previousStateIfKnown) : base(repositoryLocator.CatalogueRepository, pluginChildProviders, errorsCheckNotifier, previousStateIfKnown) { BlackListedSources = previousStateIfKnown?.BlackListedSources ?? new List <ExternalCohortTable>(); _errorsCheckNotifier = errorsCheckNotifier; dataExportRepository = repositoryLocator.DataExportRepository; AllProjectAssociatedCics = GetAllObjects <ProjectCohortIdentificationConfigurationAssociation>(dataExportRepository); _cicAssociations = new HashSet <int>(AllProjectAssociatedCics.Select(a => a.CohortIdentificationConfiguration_ID)); CohortSources = GetAllObjects <ExternalCohortTable>(dataExportRepository); ExtractableDataSets = GetAllObjects <ExtractableDataSet>(dataExportRepository); AddToDictionaries(new HashSet <object>(AllCohortIdentificationConfigurations.Where(cic => _cicAssociations.Contains(cic.ID))), new DescendancyList(AllProjectCohortIdentificationConfigurationsNode)); AddToDictionaries(new HashSet <object>(AllCohortIdentificationConfigurations.Where(cic => !_cicAssociations.Contains(cic.ID))), new DescendancyList(AllFreeCohortIdentificationConfigurationsNode)); _selectedDataSetsWithNoIsExtractionIdentifier = new HashSet <ISelectedDataSets>(dataExportRepository.GetSelectedDatasetsWithNoExtractionIdentifiers()); SelectedDataSets = GetAllObjects <SelectedDataSets>(dataExportRepository); ReportProgress("Fetching data export objects"); var dsDictionary = ExtractableDataSets.ToDictionary(ds => ds.ID, d => d); foreach (SelectedDataSets s in SelectedDataSets) { s.InjectKnown(dsDictionary[s.ExtractableDataSet_ID]); } ReportProgress("Injecting SelectedDataSets"); //This means that the ToString method in ExtractableDataSet doesn't need to go lookup catalogue info var catalogueIdDict = AllCatalogues.ToDictionary(c => c.ID, c2 => c2); foreach (ExtractableDataSet ds in ExtractableDataSets) { if (catalogueIdDict.TryGetValue(ds.Catalogue_ID, out Catalogue cata)) { ds.InjectKnown(cata); } } ReportProgress("Injecting ExtractableDataSet"); AllPackages = GetAllObjects <ExtractableDataSetPackage>(dataExportRepository); Projects = GetAllObjects <Project>(dataExportRepository); ExtractionConfigurations = GetAllObjects <ExtractionConfiguration>(dataExportRepository); ReportProgress("Get Projects and Configurations"); ExtractionConfigurationsByProject = ExtractionConfigurations.GroupBy(k => k.Project_ID).ToDictionary(gdc => gdc.Key, gdc => gdc.ToList()); ReportProgress("Grouping Extractions by Project"); AllGlobalExtractionFilterParameters = GetAllObjects <GlobalExtractionFilterParameter>(dataExportRepository); AllContainers = GetAllObjects <FilterContainer>(dataExportRepository).ToDictionary(o => o.ID, o => o); AllDeployedExtractionFilters = GetAllObjects <DeployedExtractionFilter>(dataExportRepository); _allParameters = GetAllObjects <DeployedExtractionFilterParameter>(dataExportRepository); ReportProgress("Getting Filters"); //if we are using a database repository then we can make use of the caching class DataExportFilterManagerFromChildProvider to speed up //filter contents var dbRepo = dataExportRepository as DataExportRepository; _dataExportFilterManager = dbRepo == null ? dataExportRepository.FilterManager : new DataExportFilterManagerFromChildProvider(dbRepo, this); ReportProgress("Building FilterManager"); Cohorts = GetAllObjects <ExtractableCohort>(dataExportRepository); _cohortsByOriginId = new Dictionary <int, HashSet <ExtractableCohort> >(); foreach (ExtractableCohort c in Cohorts) { if (!_cohortsByOriginId.ContainsKey(c.OriginID)) { _cohortsByOriginId.Add(c.OriginID, new HashSet <ExtractableCohort>()); } _cohortsByOriginId[c.OriginID].Add(c); } _configurationToDatasetMapping = new Dictionary <ExtractionConfiguration, List <SelectedDataSets> >(); ReportProgress("Fetching Cohorts"); GetCohortAvailability(); ReportProgress("GetCohortAvailability"); var configToSds = SelectedDataSets.GroupBy(k => k.ExtractionConfiguration_ID).ToDictionary(gdc => gdc.Key, gdc => gdc.ToList()); foreach (ExtractionConfiguration configuration in ExtractionConfigurations) { if (configToSds.TryGetValue(configuration.ID, out List <SelectedDataSets> result)) { _configurationToDatasetMapping.Add(configuration, result); } } ReportProgress("Mapping configurations to datasets"); RootCohortsNode = new AllCohortsNode(); AddChildren(RootCohortsNode, new DescendancyList(RootCohortsNode)); foreach (ExtractableDataSetPackage package in AllPackages) { AddChildren(package, new DescendancyList(package)); } ReportProgress("Packages and Cohorts"); foreach (Project p in Projects) { AddChildren(p, new DescendancyList(p)); } ReportProgress("Projects"); //work out all the Catalogues that are extractable (Catalogues are extractable if there is an ExtractableDataSet with the Catalogue_ID that matches them) var cataToEds = new Dictionary <int, ExtractableDataSet>(ExtractableDataSets.ToDictionary(k => k.Catalogue_ID)); //inject extractability into Catalogues foreach (Catalogue catalogue in AllCatalogues) { if (cataToEds.TryGetValue(catalogue.ID, out ExtractableDataSet result)) { catalogue.InjectKnown(result.GetCatalogueExtractabilityStatus()); } else { catalogue.InjectKnown(new CatalogueExtractabilityStatus(false, false)); } } ReportProgress("Catalogue extractability injection"); try { AddPipelineUseCases(new Dictionary <string, PipelineUseCase> { { "File Import", UploadFileUseCase.DesignTime() }, { "Extraction", ExtractionPipelineUseCase.DesignTime() }, { "Release", ReleaseUseCase.DesignTime() }, { "Cohort Creation", CohortCreationRequest.DesignTime() }, { "Caching", CachingPipelineUseCase.DesignTime() }, { "Aggregate Committing", CreateTableFromAggregateUseCase.DesignTime(repositoryLocator.CatalogueRepository) } }); } catch (Exception ex) { _errorsCheckNotifier.OnCheckPerformed(new CheckEventArgs("Failed to build DesignTime PipelineUseCases", CheckResult.Fail, ex)); } ReportProgress("Pipeline adding"); }