示例#1
0
        private void CheckInProgressConfiguration(ICheckNotifier notifier)
        {
            var repo = (DataExportRepository)_config.Repository;

            notifier.OnCheckPerformed(new CheckEventArgs("Found configuration '" + _config + "'", CheckResult.Success));

            var datasets = _config.GetAllExtractableDataSets().ToArray();

            foreach (ExtractableDataSet dataSet in datasets)
            {
                if (dataSet.DisableExtraction)
                {
                    notifier.OnCheckPerformed(
                        new CheckEventArgs(
                            "Dataset " + dataSet +
                            " is set to DisableExtraction=true, probably someone doesn't want you extracting this dataset at the moment",
                            CheckResult.Fail));
                }
            }

            if (!datasets.Any())
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "There are no datasets selected for open configuration '" + _config + "'",
                        CheckResult.Fail));
            }

            if (_config.Cohort_ID == null)
            {
                notifier.OnCheckPerformed(
                    new CheckEventArgs(
                        "Open configuration '" + _config + "' does not have a cohort yet",
                        CheckResult.Fail));
                return;
            }

            //make sure that it's cohort is retrievable
            repo.GetObjectByID <ExtractableCohort>((int)_config.Cohort_ID);

            if (CheckDatasets)
            {
                foreach (ISelectedDataSets s in _config.SelectedDataSets)
                {
                    new SelectedDataSetsChecker(s).Check(notifier);
                }
            }

            //globals
            if (CheckGlobals)
            {
                if (datasets.Any())
                {
                    foreach (SupportingSQLTable table in _config.GetGlobals().OfType <SupportingSQLTable>())
                    {
                        new SupportingSQLTableChecker(table).Check(notifier);
                    }
                }
            }
        }
        /// <summary>
        /// Change which column is the linkage identifier in a <see cref="Catalogue"/> either at a global level or for a specific <paramref name="inConfiguration"/>
        /// </summary>
        /// <param name="activator"></param>
        /// <param name="catalogue"></param>
        /// <param name="inConfiguration"></param>
        /// <param name="column"></param>
        public ExecuteCommandSetExtractionIdentifier(IBasicActivateItems activator,
                                                     [DemandsInitialization("The dataset you want to change the extraction identifier for")]
                                                     ICatalogue catalogue,

                                                     [DemandsInitialization("Optional - The specific extraction you want the change made in or Null for the Catalogue itself (will affect all future extractions)")]
                                                     IExtractionConfiguration inConfiguration,

                                                     [DemandsInitialization("Optional - The Column name(s) you want to select as the new linkage identifier(s).  Comma seperate multiple entries if needed")]
                                                     string column) : base(activator)
        {
            _catalogue       = catalogue;
            _inConfiguration = inConfiguration;
            _catalogue.ClearAllInjections();

            if (inConfiguration != null)
            {
                var allEds = inConfiguration.GetAllExtractableDataSets();
                var eds    = allEds.FirstOrDefault(sds => sds.Catalogue_ID == _catalogue.ID);
                if (eds == null)
                {
                    SetImpossible($"Catalogue '{_catalogue}' is not part of ExtractionConfiguration '{inConfiguration}'");
                    return;
                }

                _selectedDataSetColumns = inConfiguration.GetAllExtractableColumnsFor(eds);

                if (_selectedDataSetColumns.Length == 0)
                {
                    SetImpossible($"Catalogue '{_catalogue}' in '{inConfiguration}' does not have any extractable columns");
                    return;
                }

                _alreadyMarkedInConfiguration = _selectedDataSetColumns.Where(ei => ei.IsExtractionIdentifier).ToArray();
            }
            else
            {
                _extractionInformations = _catalogue.GetAllExtractionInformation(ExtractionCategory.Any);

                if (_extractionInformations.Length == 0)
                {
                    SetImpossible("Catalogue does not have any extractable columns");
                    return;
                }

                _alreadyMarked = _extractionInformations.Where(ei => ei.IsExtractionIdentifier).ToArray();
            }

            if (!string.IsNullOrWhiteSpace(column))
            {
                toPick = column.Split(',', StringSplitOptions.RemoveEmptyEntries);
            }
        }
示例#3
0
        public static void IdentifyAndRemoveOldExtractionResults(IRDMPPlatformRepositoryServiceLocator repo, ICheckNotifier checkNotifier, IExtractionConfiguration configuration)
        {
            var oldResults = configuration.CumulativeExtractionResults
                             .Where(cer => !configuration.GetAllExtractableDataSets().Contains(cer.ExtractableDataSet))
                             .ToArray();

            if (oldResults.Any())
            {
                string message = "In Configuration " + configuration + ":" + Environment.NewLine + Environment.NewLine +
                                 "The following CumulativeExtractionResults reflect datasets that were previously extracted under the existing Configuration but are no longer in the CURRENT configuration:";

                message = oldResults.Aggregate(message, (s, n) => s + Environment.NewLine + n);

                if (
                    checkNotifier.OnCheckPerformed(new CheckEventArgs(message, CheckResult.Fail, null,
                                                                      "Delete expired CumulativeExtractionResults for configuration." + Environment.NewLine +
                                                                      "Not doing so may result in failures at Release time.")))
                {
                    foreach (var result in oldResults)
                    {
                        result.DeleteInDatabase();
                    }
                }
            }

            var oldLostSupplemental = configuration.CumulativeExtractionResults
                                      .SelectMany(c => c.SupplementalExtractionResults)
                                      .Union(configuration.SupplementalExtractionResults)
                                      .Where(s => !repo.ArbitraryDatabaseObjectExists(s.ReferencedObjectRepositoryType, s.ReferencedObjectType, s.ReferencedObjectID))
                                      .ToArray();

            if (oldLostSupplemental.Any())
            {
                string message = "In Configuration " + configuration + ":" + Environment.NewLine + Environment.NewLine +
                                 "The following list reflect objects (supporting sql, lookups or documents) " +
                                 "that were previously extracted but have since been deleted:";

                message = oldLostSupplemental.Aggregate(message, (s, n) => s + Environment.NewLine + n.DestinationDescription);

                if (
                    checkNotifier.OnCheckPerformed(new CheckEventArgs(message, CheckResult.Fail, null,
                                                                      "Delete expired Extraction Results for configuration." + Environment.NewLine +
                                                                      "Not doing so may result in failures at Release time.")))
                {
                    foreach (var result in oldLostSupplemental)
                    {
                        result.DeleteInDatabase();
                    }
                }
            }
        }