private void CreateANormalCatalogue()
        {
            var svr = _database.Server;

            using (var con = svr.GetConnection())
            {
                con.Open();
                svr.GetCommand("CREATE TABLE NonTVFTable ( chi varchar(10))", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0101010101')", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0202020202')", con).ExecuteNonQuery();
                svr.GetCommand("INSERT INTO NonTVFTable VALUES ('0303030303')", con).ExecuteNonQuery();
            }

            var importer = new TableInfoImporter(CatalogueRepository, svr.Name,
                                                 _database.GetRuntimeName(), "NonTVFTable",
                                                 DatabaseType.MicrosoftSQLServer, _database.Server.ExplicitUsernameIfAny, _database.Server.ExplicitPasswordIfAny);

            importer.DoImport(out var tbl, out var cols);

            var engineer = new ForwardEngineerCatalogue(tbl, cols, true);

            engineer.ExecuteForwardEngineering(out var cata, out var cis, out var eis);

            _nonTvfExtractionIdentifier = eis.Single();
            _nonTvfExtractionIdentifier.IsExtractionIdentifier = true;
            _nonTvfExtractionIdentifier.SaveToDatabase();

            _nonTvfCatalogue = cata;
            _nonTvfTableInfo = tbl;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tests that the logging database for the load is reachable and that it has an appropriate logging task for the load (if not a new task will be created 'Loading X')
        /// </summary>
        /// <param name="catalogue"></param>
        public void EnsureLoggingWorksFor(ICatalogue catalogue)
        {
            //if there's no logging task / logging server set them up with the same name as the lmd
            IExternalDatabaseServer loggingServer;

            if (catalogue.LiveLoggingServer_ID == null)
            {
                loggingServer = CatalogueRepository.GetServerDefaults().GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID);

                if (loggingServer != null)
                {
                    catalogue.LiveLoggingServer_ID = loggingServer.ID;
                }
                else
                {
                    throw new NotSupportedException("You do not yet have any logging servers configured so cannot create data loads");
                }
            }
            else
            {
                loggingServer = Repository.GetObjectByID <ExternalDatabaseServer>(catalogue.LiveLoggingServer_ID.Value);
            }

            //if there's no logging task yet and there's a logging server
            if (string.IsNullOrWhiteSpace(catalogue.LoggingDataTask))
            {
                var lm = new LogManager(loggingServer);
                var loggingTaskName = Name;

                lm.CreateNewLoggingTaskIfNotExists(loggingTaskName);
                catalogue.LoggingDataTask = loggingTaskName;
                catalogue.SaveToDatabase();
            }
        }
Ejemplo n.º 3
0
 public Form1(ICatalogue catalogue)
 {
     this.catalogue = catalogue;
     InitializeComponent();
     catalogue.CatalogueChanged += CatalogueOnCatalogueChanged;
     UpdateProductList();
 }
Ejemplo n.º 4
0
        public CatalogueItem ShallowClone(ICatalogue into)
        {
            var clone = new CatalogueItem(CatalogueRepository, into, Name);

            CopyShallowValuesTo(clone);
            return(clone);
        }
Ejemplo n.º 5
0
 public void Add(ICatalogue catalogue)
 {
     foreach (var ei in catalogue.GetAllExtractionInformation(ExtractionCategory.Any))
     {
         Add(ei);
     }
 }
        private void ConfigureAndExecutePipeline1OnPipelineExecutionFinishedsuccessfully(object sender, PipelineEngineEventArgs args)
        {
            //pipeline executed successfully
            if (_alsoForwardEngineerCatalogue)
            {
                string targetTable = null;

                try
                {
                    var dest = (DataTableUploadDestination)args.PipelineEngine.DestinationObject;
                    targetTable = dest.TargetTableName;
                    var table = _database.ExpectTable(targetTable);

                    var ui = new ConfigureCatalogueExtractabilityUI(_activator, new TableInfoImporter(_repositoryLocator.CatalogueRepository, table), "File '" + _file.FullName + "'", _projectSpecific);
                    ui.ShowDialog();

                    var cata = CatalogueCreatedIfAny = ui.CatalogueCreatedIfAny;

                    if (cata != null)
                    {
                        MessageBox.Show("Catalogue " + cata.Name + " successfully created");
                    }
                    else
                    {
                        MessageBox.Show("User cancelled Catalogue creation, data has been loaded and TableInfo/ColumnInfos exist in Data Catalogue but there will be no Catalogue");
                    }

                    this.ParentForm.Close();
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show("Failed to import TableInfo/Forward Engineer Catalogue from " + _database.ToString() + "(Table was " + (targetTable ?? "Null!") + ")" + " - see Exception for details", e);
                }
            }
        }
Ejemplo n.º 7
0
 public Checkout(ICatalogue catalogue, IDiscounts discounts)
 {
     _subtotal      = new Price();
     _scannedItems  = new Collection <IPurchaseable>();
     _itemCatalogue = catalogue;
     _discounts     = discounts;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a new AggregateGraph for the given dataset (<paramref name="cata"/>)
        /// </summary>
        /// <param name="cata"></param>
        /// <param name="name">The name to give the graph</param>
        /// <param name="dimension1">The first dimension e.g. pass only one dimension to create a bar chart</param>
        /// <param name="isAxis">True if <paramref name="dimension1"/> should be created as a axis (creates a line chart)</param>
        /// <param name="dimension2">Optional second dimension to create (this will be the pivot column)</param>
        private AggregateConfiguration CreateGraph(ICatalogue cata, string name, string dimension1, bool isAxis, string dimension2)
        {
            var ac = new AggregateConfiguration(_repos.CatalogueRepository, cata, name);

            ac.CountSQL = "count(*) as NumberOfRecords";
            ac.SaveToDatabase();
            ac.IsExtractable = true;

            var mainDimension  = ac.AddDimension(GetExtractionInformation(cata, dimension1));
            var otherDimension = string.IsNullOrWhiteSpace(dimension2) ? null : ac.AddDimension(GetExtractionInformation(cata, dimension2));

            if (isAxis)
            {
                var axis = new AggregateContinuousDateAxis(_repos.CatalogueRepository, mainDimension);
                axis.StartDate     = "'1970-01-01'";
                axis.AxisIncrement = FAnsi.Discovery.QuerySyntax.Aggregation.AxisIncrement.Year;
                axis.SaveToDatabase();
            }

            if (otherDimension != null)
            {
                ac.PivotOnDimensionID = otherDimension.ID;
                ac.SaveToDatabase();
            }

            return(ac);
        }
Ejemplo n.º 9
0
 private void ForExtractionInformations(ICatalogue catalogue, Action <ExtractionInformation> action, params string[] extractionInformations)
 {
     foreach (var e in extractionInformations.Select(s => GetExtractionInformation(catalogue, s)))
     {
         action(e);
     }
 }
Ejemplo n.º 10
0
        private IColumn GetExtractionIdentifierFrom(ICatalogue catalogue, ChooseWhichExtractionIdentifierToUseFromManyHandler resolveMultipleExtractionIdentifiers)
        {
            //the aggregate they are cloning does not have an extraction identifier but the dataset might still have one
            var catalogueCandidates = catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Where(e => e.IsExtractionIdentifier).ToArray();

            //if there are multiple IsExtractionInformation columns
            if (catalogueCandidates.Count() != 1)
            {
                if (resolveMultipleExtractionIdentifiers == null)//no delegate has been provided for resolving this
                {
                    throw new NotSupportedException("Cannot create AggregateConfiguration because the Catalogue " + catalogue + " has " + catalogueCandidates.Length + " IsExtractionIdentifier ExtractionInformations");
                }
                else
                {
                    //there is a delegate to resolve this, invoke it
                    var answer = resolveMultipleExtractionIdentifiers(catalogue, catalogueCandidates);

                    //the delegate returned null
                    if (answer == null)
                    {
                        throw new Exception("User did not pick a candidate ExtractionInformation column from those we offered");
                    }
                    else
                    {
                        return(answer);//the delegate picked one
                    }
                }
            }

            return(catalogueCandidates[0]);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates a new cohort set <see cref="AggregateConfiguration"/> which initially matches any patient appearing in the dataset (<see cref="Catalogue"/>).
        /// <para>IMPORTANT: It must be possible to select a single column from which to harvest the patient identifiers from <paramref name="resolveMultipleExtractionIdentifiers"/></para>
        /// </summary>
        /// <param name="catalogue">The catalogue to import as a patient identification set (you can import the same Catalogue multiple times e.g.
        /// 'People ever prescribed morphine' EXCEPT 'People ever prescribed percoset'</param>
        /// <param name="resolveMultipleExtractionIdentifiers">What to do if there are multiple <see cref="ExtractionInformation"/>
        ///  marked IsExtractionIdentifier</param>
        /// <param name="importMandatoryFilters"></param>
        /// <returns></returns>
        public AggregateConfiguration CreateNewEmptyConfigurationForCatalogue(ICatalogue catalogue, ChooseWhichExtractionIdentifierToUseFromManyHandler resolveMultipleExtractionIdentifiers, bool importMandatoryFilters = true)
        {
            var cataRepo = (ICatalogueRepository)Repository;

            AggregateConfiguration configuration = new AggregateConfiguration(cataRepo, catalogue, "People in " + catalogue);

            EnsureNamingConvention(configuration);

            if (!catalogue.IsApiCall())
            {
                var extractionIdentifier = (ExtractionInformation)GetExtractionIdentifierFrom(catalogue, resolveMultipleExtractionIdentifiers);
                //make the extraction identifier column into the sole dimension on the new configuration
                new AggregateDimension(cataRepo, extractionIdentifier, configuration);
            }

            //no count sql
            configuration.CountSQL = null;
            configuration.SaveToDatabase();

            if (importMandatoryFilters)
            {
                ImportMandatoryFilters(catalogue, configuration, GetAllParameters());
            }

            return(configuration);
        }
Ejemplo n.º 12
0
        public void CommitToDatabase(Evaluation evaluation, ICatalogue catalogue, DbConnection con, DbTransaction transaction)
        {
            if (!_correctValuesCalculated)
            {
                throw new Exception("You must call CalculateFinalValues before committing to the database");
            }

            IEnumerable <int> novelDataLoadRunIDs = RowsPassingValidationByDataLoadRunID.Keys;

            //now for every load batch we encountered in our evaluations
            foreach (int dataLoadRunID in novelDataLoadRunIDs)
            {
                //record the row states calculation (how many total rows are good/bad/ugly etc)
                evaluation.AddRowState(dataLoadRunID,
                                       RowsPassingValidationByDataLoadRunID[dataLoadRunID],
                                       WorstConsequencesByDataLoadRunID[dataLoadRunID][Consequence.Missing],
                                       WorstConsequencesByDataLoadRunID[dataLoadRunID][Consequence.Wrong],
                                       WorstConsequencesByDataLoadRunID[dataLoadRunID][Consequence.InvalidatesRow],
                                       catalogue.ValidatorXML,
                                       _pivotCategory,
                                       con,
                                       transaction
                                       );

                //record the column states calculations (how many total values in column x are good/bad/ugly etc)
                foreach (var columnState in AllColumnStates[dataLoadRunID])
                {
                    columnState.Commit(evaluation, _pivotCategory, con, transaction);
                }
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new supporting document for helping understand the dataset <paramref name="parent"/>
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parent"></param>
 /// <param name="name"></param>
 public SupportingDocument(ICatalogueRepository repository, ICatalogue parent, string name)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "Name", name },
         { "Catalogue_ID", parent.ID }
     });
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates a new folder that the Catalogue should now reside in.
        /// <para><remarks>After calling this you should use <code>parent.Folder = instance; parent.SaveToDatabase();</code></remarks></para>
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="folder"></param>
        public CatalogueFolder(ICatalogue parent, string folder)
        {
            //always Lower everything!
            folder = folder.ToLower();

            _parent = parent;
            Path    = folder;
        }
Ejemplo n.º 15
0
 /// <inheritdoc/>
 public bool HasEvaluations(ICatalogue catalogue)
 {
     using (var con = GetConnection())
     {
         //get all the row level data 1 to 1 join with evaluation
         using (var cmdGetEvaluations = DatabaseCommandHelper.GetCommand("select count(*) from Evaluation where CatalogueID = " + catalogue.ID, con.Connection, con.Transaction))
             return(Convert.ToInt32(cmdGetEvaluations.ExecuteScalar()) > 0);
     }
 }
Ejemplo n.º 16
0
        private string GetSql(ICatalogue mainCata)
        {
            mainCata.ClearAllInjections();

            var qb = new QueryBuilder(null, null);

            qb.AddColumnRange(mainCata.GetAllExtractionInformation(ExtractionCategory.Any));
            return(qb.SQL);
        }
Ejemplo n.º 17
0
        public ForwardEngineerANOCataloguePlanManager(IRDMPPlatformRepositoryServiceLocator repositoryLocator, ICatalogue catalogue) : this(repositoryLocator)
        {
            Catalogue = catalogue;

            foreach (var plan in Plans.Values)
            {
                plan.SetToRecommendedPlan();
            }
        }
Ejemplo n.º 18
0
 private void ConfigureCatalogueExtractabilityUI_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!_choicesFinalised)
     {
         if (_importedNewTable)
         {
             var confirm = MessageBox.Show("The database table was created as part of this import. Do you want to keep that?",
                                           "Confirm", MessageBoxButtons.YesNoCancel);
             if (confirm != DialogResult.Cancel)
             {
                 DialogResult = DialogResult.Cancel;
                 _catalogue.DeleteInDatabase();
                 _catalogue = null;
                 if (confirm == DialogResult.No)
                 {
                     _tableInfo.DeleteInDatabase();
                     _tableInfo = null;
                     if (TableCreated != null && TableCreated.Exists())
                     {
                         TableCreated.Drop();
                     }
                 }
                 else
                 {
                     Activator.Publish(TableInfoCreated);
                 }
             }
             else
             {
                 e.Cancel = true;
             }
         }
         else
         {
             if (MessageBox.Show(
                     "Are you sure you want to Cancel?",
                     "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 DialogResult = DialogResult.Cancel;
                 _catalogue.DeleteInDatabase();
                 _catalogue = null;
             }
             else
             {
                 e.Cancel = true;
             }
         }
     }
     else
     {
         if (CatalogueCreatedIfAny != null)
         {
             Activator.Publish(CatalogueCreatedIfAny);
         }
     }
 }
Ejemplo n.º 19
0
        public virtual bool CatalogueSupportsReport(ICatalogue c)
        {
            _catalogue = c;

            ToMemoryCheckNotifier checkNotifier = new ToMemoryCheckNotifier();

            Check(checkNotifier);

            return(checkNotifier.GetWorst() <= CheckResult.Warning);
        }
Ejemplo n.º 20
0
 public static Catalogue Create(ICatalogue catalogue)
 {
     return(new Catalogue()
     {
         CODE = catalogue.CODE,
         Name = catalogue.Name,
         Description = catalogue.Description,
         Tags = new Dictionary <string, string>(catalogue.Tags),
     });
 }
Ejemplo n.º 21
0
        /// <inheritdoc/>
        public override void DeleteInDatabase()
        {
            ICatalogue firstOrDefault = GetAllCatalogues().FirstOrDefault();

            if (firstOrDefault != null)
            {
                throw new Exception("This load is used by " + firstOrDefault.Name + " so cannot be deleted (Disassociate it first)");
            }

            base.DeleteInDatabase();
        }
Ejemplo n.º 22
0
 private ExtractionInformation GetExtractionInformation(ICatalogue cata, string name)
 {
     try
     {
         return(cata.GetAllExtractionInformation(ExtractionCategory.Any).Single(ei => ei.GetRuntimeName().Equals(name, StringComparison.CurrentCultureIgnoreCase)));
     }
     catch
     {
         throw new Exception("Could not find an ExtractionInformation called '" + name + "' in dataset " + cata.Name);
     }
 }
Ejemplo n.º 23
0
        public CatalogueExtractabilityStatus GetExtractabilityStatus(ICatalogue c)
        {
            var eds = GetAllObjectsWithParent <ExtractableDataSet>(c).SingleOrDefault();

            if (eds == null)
            {
                return(new CatalogueExtractabilityStatus(false, false));
            }

            return(new CatalogueExtractabilityStatus(true, eds.Project_ID != null));
        }
Ejemplo n.º 24
0
        public DataLoadProgressUpdateInfoTests()
        {
            ICatalogue cata = Mock.Of <ICatalogue>(
                c => c.LoggingDataTask == "NothingTask" &&
                c.GetTableInfoList(false) == new TableInfo[0] &&
                c.GetLookupTableInfoList() == new TableInfo[0]);

            var lmd = Mock.Of <ILoadMetadata>(m => m.GetAllCatalogues() == new[] { cata });

            _job = new ScheduledDataLoadJob(null, "fish", Mock.Of <ILogManager>(), lmd, null, new ThrowImmediatelyDataLoadJob(), null);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates a new virtual column description for for a column in the dataset (<paramref name="parent"/>) supplied with the given Name.
        /// <para><remarks>You should next choose which <see cref="ColumnInfo"/> powers it and optionally create an <see cref="ExtractionInformation"/> to
        /// make the column extractable</remarks></para>
        /// </summary>
        public CatalogueItem(ICatalogueRepository repository, ICatalogue parent, string name)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "Catalogue_ID", parent.ID }
            });

            ClearAllInjections();
            parent.ClearAllInjections();
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Starts a new evaluation with the given transaction
        /// </summary>
        internal Evaluation(DQERepository dqeRepository, ICatalogue c)
        {
            DQERepository = dqeRepository;
            Catalogue     = c;

            dqeRepository.InsertAndHydrate(this,
                                           new Dictionary <string, object>()
            {
                { "CatalogueID", c.ID },
                { "DateOfEvaluation", DateTime.Now }
            });
        }
Ejemplo n.º 27
0
        public ExecuteCommandAddTag(BasicActivateItems activator, ICatalogue catalogue,
                                    [DemandsInitialization("Name of the new column you want created.")]
                                    string column,
                                    [DemandsInitialization("Optional when column is the name of a Dicom Tag e.g. StudyInstanceUID")]
                                    string dataType) : base(activator)
        {
            var tables = catalogue.GetTableInfosIdeallyJustFromMainTables();

            if (tables.Length != 1)
            {
                SetImpossible($"There are {tables.Length} tables mapped under Catalogue {catalogue}");
                return;
            }

            if (string.IsNullOrWhiteSpace(column))
            {
                SetImpossible("Column name must be supplied");
                return;
            }

            var syntax = tables[0].GetQuerySyntaxHelper();

            //if user hasn't listed a specific datatype, guess it from the column
            if (string.IsNullOrWhiteSpace(dataType))
            {
                var available = TagColumnAdder.GetAvailableTags();

                if (!available.Contains(column))
                {
                    var similar = available.Where(c => c.Contains(column)).ToArray();

                    if (similar.Any())
                    {
                        SetImpossible($"Could not find a tag called '{column}'. Possibly  you meant:" + Environment.NewLine + string.Join(Environment.NewLine, similar));
                        return;
                    }

                    SetImpossible($"Could not find a tag called '{column}' or any like it");
                    return;
                }

                try
                {
                    dataType = TagColumnAdder.GetDataTypeForTag(column, syntax.TypeTranslater);
                }
                catch (Exception e)
                {
                    throw new Exception("No dataType was specified and column name could not be resolved to a DicomTag", e);
                }
            }

            _adder = new TagColumnAdder(column, dataType, (TableInfo)tables[0], new AcceptAllCheckNotifier());
        }
Ejemplo n.º 28
0
        public ExecuteCommandImportFilterContainerTree(IBasicActivateItems activator, IRootFilterContainerHost into) : this(activator)
        {
            _into = into;

            if (into.RootFilterContainer_ID != null)
            {
                SetImpossible("Dataset already has a root container");
            }


            _catalogue = _into.GetCatalogue();
        }
        /// <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);
            }
        }
Ejemplo n.º 30
0
        private ExtractionInformation GetExtractionInformationFromCatalogue(ICatalogue catalogue)
        {

            var eis = catalogue.GetAllExtractionInformation(ExtractionCategory.Any);

            if (eis.Count(ei => ei.IsExtractionIdentifier) != 1)
            {
                SetImpossible("Catalogue must have a single IsExtractionIdentifier column");
                return null;
            }

            return eis.Single(e => e.IsExtractionIdentifier);
        }
 public CatalogueLogic(string assemblyName)
 {
     var collectionFactory = new CollectionFactory(assemblyName);
     _catalogueSite = collectionFactory.CreateCatalogueSecretary();
 }