Ejemplo n.º 1
0
 /// <inheritdoc cref="ILoadProgress"/>
 public LoadProgress(ICatalogueRepository repository, LoadMetadata parent)
 {
     repository.InsertAndHydrate(this,
                                 new Dictionary <string, object>()
     {
         { "Name", Guid.NewGuid().ToString() },
         { "LoadMetadata_ID", parent.ID }
     });
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new empty <see cref="Pipeline"/> in the database, this is a sequence of <see cref="PipelineComponent"/> which when combined
        /// with an <see cref="IPipelineUseCase"/> achieve a specific goal (e.g. loading records into the database from a flat file).
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public Pipeline(ICatalogueRepository repository, string name = null)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name ?? "NewPipeline " + Guid.NewGuid() }
            });

            ClearAllInjections();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new argument storage object for one of the arguments in <see cref="PipelineComponent"/>.
 ///
 /// <para>You should probably call <see cref="IArgumentHost.CreateArgumentsForClassIfNotExists{T}"/> intead</para>
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parent"></param>
 public PipelineComponentArgument(ICatalogueRepository repository, PipelineComponent parent)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>()
     {
         { "PipelineComponent_ID", parent.ID },
         { "Name", "Parameter" + Guid.NewGuid() },
         { "Type", typeof(string).ToString() }
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a record of what value to use with the given <see cref="ISqlParameter"/> of the <see cref="ExtractionFilterParameterSet"/> <see cref="IFilter"/> to achieve the concept.
        ///
        /// <para>For example if there is an <see cref="ExtractionFilter"/> 'Prescribed Drug X' with a parameter @DrugList and you create an <see cref="ExtractionFilterParameterSet"/>
        /// 'Diabetic Drugs' then this will create a <see cref="ExtractionFilterParameterSetValue"/> of '@DrugList='123.23,121,2... etc'.</para>
        ///
        /// <para>If a filter has more than one parameter then you will need one <see cref="ExtractionFilterParameterSetValue"/> per parameter per <see cref="ExtractionFilterParameterSet"/></para>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="parent"></param>
        /// <param name="valueIsForParameter"></param>
        public ExtractionFilterParameterSetValue(ICatalogueRepository repository, ExtractionFilterParameterSet parent, ExtractionFilterParameter valueIsForParameter)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "ExtractionFilterParameterSet_ID", parent.ID },
                { "ExtractionFilterParameter_ID", valueIsForParameter.ID }
            });

            ClearAllInjections();
        }
        /// <summary>
        /// Defines a new set of known parameter values to achieve a given goal (e.g. identify 'diabetic drugs' in dataset prescriptions) in combination with a parent <see cref="IFilter"/>.
        /// <para>A single <see cref="ExtractionFilter"/> (e.g. 'Drug Prescriptions of X' with parameter @DrugList) could have many <see cref="ExtractionFilterParameterSet"/></para>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="filter"></param>
        /// <param name="name"></param>
        public ExtractionFilterParameterSet(ICatalogueRepository repository, ExtractionFilter filter, string name = null)
        {
            name = name ?? "New ExtractionFilterParameterSet " + Guid.NewGuid();

            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "Name", name },
                { "ExtractionFilter_ID", filter.ID }
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Declares a new configuration for identifying patient lists matching a study requirements based on the results of cohort sets / patient index tables and set operations
        /// <see cref="CohortIdentificationConfiguration"/>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public CohortIdentificationConfiguration(ICatalogueRepository repository, string name)
        {
            var queryCache = repository.GetServerDefaults().GetDefaultFor(PermissableDefaults.CohortIdentificationQueryCachingServer_ID);

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "QueryCachingServer_ID", queryCache == null ? (object)DBNull.Value:queryCache.ID }
            });
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Records the fact that the given <see cref="DashboardControl"/> targets the given object (and hopefully displays information about it)
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parentControl"></param>
 /// <param name="objectToSave"></param>
 public DashboardObjectUse(ICatalogueRepository repository, DashboardControl parentControl, IMapsDirectlyToDatabaseTable objectToSave)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "ReferencedObjectID", objectToSave.ID },
         { "ReferencedObjectType", objectToSave.GetType().Name },
         { "ReferencedObjectRepositoryType", objectToSave.Repository.GetType().Name },
         { "DashboardControl_ID", parentControl.ID },
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Declares that a new <see cref="ISqlParameter"/> (e.g. 'DECLARE @bob as varchar(10)') exists for the parent database object.  The object
 /// should be of a type which passes <see cref="IsSupportedType"/>.  When the object is used for query generation by an <see cref="QueryBuilding.ISqlQueryBuilder"/>
 /// then the parameter will be used
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parent"></param>
 /// <param name="parameterSQL"></param>
 public AnyTableSqlParameter(ICatalogueRepository repository, IMapsDirectlyToDatabaseTable parent, string parameterSQL)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "ReferencedObjectID", parent.ID },
         { "ReferencedObjectType", parent.GetType().Name },
         { "ReferencedObjectRepositoryType", parent.Repository.GetType().Name },
         { "ParameterSQL", parameterSQL },
     });
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates a new <see cref="GovernancePeriod"/> in the database.  This grants (ethical) permission to hold datasets referenced by <see cref="GovernedCatalogues"/>.
        /// </summary>
        /// <param name="repository"></param>
        public GovernancePeriod(ICatalogueRepository repository)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", "GovernancePeriod" + Guid.NewGuid() },
                { "StartDate", DateTime.Now }
            });

            _manager = CatalogueRepository.GovernanceManager;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Creates a new empty dashboard with the given name ready for controls to be added by the user
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public DashboardLayout(ICatalogueRepository repository, string name)
        {
            Repository = repository;

            Repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "Username", Environment.UserName },
                { "Name", name }
            });
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Defines a new collection of dlls that provide plugin functionality for RDMP
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="pluginZipFile"></param>
 /// <param name="pluginVersion"></param>
 /// <param name="rdmpVersion"></param>
 public Plugin(ICatalogueRepository repository, FileInfo pluginZipFile, Version pluginVersion, Version rdmpVersion)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>()
     {
         { "Name", pluginZipFile.Name },
         { "UploadedFromDirectory", pluginZipFile.DirectoryName },
         { "PluginVersion", (pluginVersion ?? new Version(0, 0, 0, 0)) },
         { "RdmpVersion", (rdmpVersion ?? new Version(0, 0, 0, 0)) }
     });
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Creates a new WHERE SQL block for reuse with the <see cref="Catalogue"/> in which the <paramref name="parent"/> resides.  This is a top level master filter and can be
        /// copied out in <see cref="CohortIdentificationConfiguration"/>, ExtractionConfiguration etc.  This ensures a single curated block of
        /// logic that everyone shares.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        /// <param name="parent"></param>
        public ExtractionFilter(ICatalogueRepository repository, string name, ExtractionInformation parent)
        {
            name = name ?? "New Filter " + Guid.NewGuid();

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "ExtractionInformation_ID", parent.ID }
            });
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Uploads the given dll file to the catalogue database ready for use as a plugin within RDMP (also uploads any pdb file in the same dir)
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="f"></param>
        /// <param name="plugin"></param>
        public LoadModuleAssembly(ICatalogueRepository repository, FileInfo f, Plugin plugin)
        {
            var dictionaryParameters = GetDictionaryParameters(f, plugin);

            //so we can reference it in fetch requests to check for duplication (normaly Repository is set during hydration by the repo)
            Repository = repository;

            Repository.InsertAndHydrate(this, dictionaryParameters);
            ClearAllInjections();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Defines a new filter (line of WHERE SQL) in the specified AggregateFilterContainer (AND / OR).  Calling this constructor creates a new object in the database
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        /// <param name="container"></param>
        public AggregateFilter(ICatalogueRepository repository, string name = null, AggregateFilterContainer container = null)
        {
            name = name ?? "New AggregateFilter" + Guid.NewGuid();

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "FilterContainer_ID", container != null ? (object)container.ID : DBNull.Value }
            });
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Create a new DLE load.  This load will not have any <see cref="ProcessTask"/> and will not load any <see cref="TableInfo"/> yet.
 ///
 /// <para>To set the loaded tables, set <see cref="Catalogue.LoadMetadata_ID"/> on some of your datasets</para>
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="name"></param>
 public LoadMetadata(ICatalogueRepository repository, string name = null)
 {
     if (name == null)
     {
         name = "NewLoadMetadata" + Guid.NewGuid();
     }
     repository.InsertAndHydrate(this, new Dictionary <string, object>()
     {
         { "Name", name }
     });
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new container (which starts out as an oprhan) with the given <see cref="SetOperation"/>.  You should either set a
        ///  <see cref="CohortIdentificationConfiguration.RootCohortAggregateContainer_ID"/> to this.<see cref="IMapsDirectlyToDatabaseTable.ID"/> to make this container the root container
        /// or use <see cref="AddChild(CohortAggregateContainer)"/>  on another container to make this a subcontainer of it.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="operation"></param>
        public CohortAggregateContainer(ICatalogueRepository repository, SetOperation operation)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Operation", operation.ToString() },
                { "Order", 0 },
                { "Name", operation.ToString() }
            });

            _manager = repository.CohortContainerManager;
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Defines that the specified column (<see cref="AggregateDimension"/>) should function as the continuous axis of an <see cref="AggregateConfiguration"/> graph.
        /// For example if you are graphing the number of prescriptions given out each month then the axis would be applied to the 'PrescribedDate' <see cref="AggregateDimension"/>
        ///  </summary>
        /// <remarks>To use this you will first have to create an AggregateConfiguration and setup the count(*)/sum(*) etc stuff and then add a new AggregateDimension <see cref="AggregateConfiguration.AddDimension"/> </remarks>
        /// <param name="repository"></param>
        /// <param name="dimension"></param>
        public AggregateContinuousDateAxis(ICatalogueRepository repository, AggregateDimension dimension)
        {
            var todaysDateFunction = dimension.AggregateConfiguration.GetQuerySyntaxHelper().GetScalarFunctionSql(MandatoryScalarFunctions.GetTodaysDate);

            repository.InsertAndHydrate(this,
                                        new Dictionary <string, object>()
            {
                { "AggregateDimension_ID", dimension.ID },
                { "EndDate", todaysDateFunction }
            });
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Creates a new component in the <paramref name="parent"/> <see cref="Pipeline"/>.  This will mean that when run the <see cref="Pipeline"/>
 /// will instantiate and run the given <paramref name="componentType"/>.
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="parent"></param>
 /// <param name="componentType"></param>
 /// <param name="order"></param>
 /// <param name="name"></param>
 public PipelineComponent(ICatalogueRepository repository, IPipeline parent, Type componentType, int order,
                          string name = null)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "Name", name ?? "Run " + componentType.Name },
         { "Pipeline_ID", parent.ID },
         { "Class", componentType.ToString() },
         { "Order", order }
     });
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates a new virtual column that will be created in RAW during data loads but does not appear in the LIVE table schema.  This allows
        /// identifiable data to be loaded and processed in a data load without ever hitting the live database.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="parent"></param>
        /// <param name="name"></param>
        public PreLoadDiscardedColumn(ICatalogueRepository repository, ITableInfo parent, string name = null)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "TableInfo_ID", parent.ID },
                { "Destination", DiscardedColumnDestination.Oblivion },
                { "RuntimeColumnName", name ?? "NewColumn" + Guid.NewGuid() }
            });

            ClearAllInjections();
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Records that the current Environment.UserName wants to mark the <paramref name="objectToFavourite"/> as one of his favourite objects
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="objectToFavourite"></param>
 public Favourite(ICatalogueRepository repository, IMapsDirectlyToDatabaseTable objectToFavourite)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "ReferencedObjectID", objectToFavourite.ID },
         { "ReferencedObjectType", objectToFavourite.GetType().Name },
         { "ReferencedObjectRepositoryType", objectToFavourite.Repository.GetType().Name },
         { "Username", Environment.UserName },
         { "FavouritedDate", DateTime.Now },
     });
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Records a new (initially blank) set of credentials that can be used to access a <see cref="TableInfo"/> or other object requiring authentication.
        /// <para>A single <see cref="DataAccessCredentials"/> can be shared by multiple tables</para>
        ///
        /// <para>You can also use <see cref="DataAccessCredentialsFactory"/> for easier credentials creation</para>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public DataAccessCredentials(ICatalogueRepository repository, string name = null)
        {
            name = name ?? "New Credentials " + Guid.NewGuid();

            _encryptedPasswordHost = new EncryptedPasswordHost(repository);

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name }
            });
        }
Ejemplo n.º 22
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, Catalogue parent, string name)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "Catalogue_ID", parent.ID }
            });

            ClearAllInjections();
            parent.ClearAllInjections();
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Documents that a given cache fetch request was not succesfully executed e.g. the remote endpoint returned an error for that date range.
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="cacheProgress"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 /// <param name="e"></param>
 public CacheFetchFailure(ICatalogueRepository repository, ICacheProgress cacheProgress, DateTime start, DateTime end, Exception e)
 {
     repository.InsertAndHydrate(this, new Dictionary <string, object>
     {
         { "CacheProgress_ID", cacheProgress.ID },
         { "FetchRequestStart", start },
         { "FetchRequestEnd", end },
         { "ExceptionText", ExceptionHelper.ExceptionToListOfInnerMessages(e, true) },
         { "LastAttempt", DateTime.Now },
         { "ResolvedOn", DBNull.Value }
     });
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Create a new DLE load.  This load will not have any <see cref="ProcessTask"/> and will not load any <see cref="TableInfo"/> yet.
 ///
 /// <para>To set the loaded tables, set <see cref="Catalogue.LoadMetadata_ID"/> on some of your datasets</para>
 /// </summary>
 /// <param name="repository"></param>
 /// <param name="name"></param>
 public LoadMetadata(ICatalogueRepository repository, string name = null)
 {
     if (name == null)
     {
         name = "NewLoadMetadata" + Guid.NewGuid();
     }
     repository.InsertAndHydrate(this, new Dictionary <string, object>()
     {
         { "Name", name },
         { "IgnoreTrigger", false /*todo could be system global default here*/ }
     });
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Record the new layout in the database
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name">Human readable name for the layout</param>
        /// <param name="layoutXml">The layout Xml of RDMPMainForm, use GetCurrentLayoutXml to get this, cannot be null</param>
        public WindowLayout(ICatalogueRepository repository, string name, string layoutXml)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "Name", name },
                { "LayoutData", layoutXml }
            });

            if (ID == 0 || Repository != repository)
            {
                throw new ArgumentException("Repository failed to properly hydrate this class");
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Creates a new operation in the data load (e.g. copy files from A to B, load all CSV files to RAW table B etc)
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="parent"></param>
        /// <param name="stage"></param>
        public ProcessTask(ICatalogueRepository repository, ILoadMetadata parent, LoadStage stage)
        {
            var order = repository.GetAllObjectsWithParent <ProcessTask>(parent).Select(t => t.Order).DefaultIfEmpty().Max() + 1;

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "LoadMetadata_ID", parent.ID },
                { "ProcessTaskType", ProcessTaskType.Executable.ToString() },
                { "LoadStage", stage },
                { "Name", "New Process" + Guid.NewGuid() },
                { "Order", order }
            });
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates a new AggregateConfiguration (graph, cohort set or patient index table) in the ICatalogueRepository
        /// . database associated with the provided Catalogue (dataset).
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="catalogue"></param>
        /// <param name="name"></param>
        public AggregateConfiguration(ICatalogueRepository repository, ICatalogue catalogue, string name)
        {
            //default values
            CountSQL  = "count(*)";
            dtCreated = DateTime.Now;

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "Catalogue_ID", catalogue.ID }
            });

            ClearAllInjections();
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Defines a new keyword that should be set on all connections to databases of <see cref="DatabaseType"/> when making new connections
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="databaseType"></param>
        /// <param name="keyword"></param>
        /// <param name="value"></param>
        public ConnectionStringKeyword(ICatalogueRepository repository, DatabaseType databaseType, string keyword, string value)
        {
            repository.InsertAndHydrate(this, new Dictionary <string, object>()
            {
                { "DatabaseType", databaseType.ToString() },
                { "Name", keyword },
                { "Value", value },
            });

            if (ID == 0 || Repository != repository)
            {
                throw new ArgumentException("Repository failed to properly hydrate this class");
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Defines a new table reference in the platform database <paramref name="repository"/>.
        /// <para>Usually you should use <see cref="TableInfoImporter"/> instead</para>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="name"></param>
        public TableInfo(ICatalogueRepository repository, string name)
        {
            _catalogueRepository = repository;

            var dumpServer = repository.GetServerDefaults().GetDefaultFor(PermissableDefaults.IdentifierDumpServer_ID);

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "Name", name },
                { "IdentifierDumpServer_ID", dumpServer == null ? (object)DBNull.Value:dumpServer.ID }
            });

            ClearAllInjections();
        }
Ejemplo n.º 30
0
Archivo: ANOTable.cs Proyecto: rkm/RDMP
        /// <summary>
        /// Declares that a new ANOTable (anonymous mapping table) should exist in the referenced database.  You can call this constructor without first creating the table.  If you do
        /// you should set <see cref="NumberOfIntegersToUseInAnonymousRepresentation"/> and <see cref="NumberOfCharactersToUseInAnonymousRepresentation"/> then <see cref="PushToANOServerAsNewTable"/>
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="externalDatabaseServer"></param>
        /// <param name="tableName"></param>
        /// <param name="suffix"></param>
        public ANOTable(ICatalogueRepository repository, ExternalDatabaseServer externalDatabaseServer, string tableName, string suffix)
        {
            if (string.IsNullOrWhiteSpace(tableName))
            {
                throw new NullReferenceException("ANOTable must have a name");
            }

            repository.InsertAndHydrate(this, new Dictionary <string, object>
            {
                { "TableName", tableName },
                { "Suffix", suffix },
                { "Server_ID", externalDatabaseServer.ID }
            });
        }