• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

HicServices / RDMP / 6245535001

20 Sep 2023 07:44AM UTC coverage: 57.013%. First build
6245535001

push

github

web-flow
8.1.0 Release (#1628)

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 13.0.1 to 13.0.2.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/13.0.1...13.0.2)

---
updated-dependencies:
- dependency-name: Newtonsoft.Json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

Bumps [NLog](https://github.com/NLog/NLog) from 5.0.5 to 5.1.0.
- [Release notes](https://github.com/NLog/NLog/releases)
- [Changelog](https://github.com/NLog/NLog/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/NLog/NLog/compare/v5.0.5...v5.1.0)

---
updated-dependencies:
- dependency-name: NLog
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump NLog from 5.0.5 to 5.1.0

* Fix -r flag - should have been --results-directory all along

* Bump Newtonsoft.Json from 13.0.1 to 13.0.2

* Bump YamlDotNet from 12.0.2 to 12.1.0

Bumps [YamlDotNet](https://github.com/aaubry/YamlDotNet) from 12.0.2 to 12.1.0.
- [Release notes](https://github.com/aaubry/YamlDotNet/releases)
- [Commits](https://github.com/aaubry/YamlDotNet/compare/v12.0.2...v12.1.0)

---
updated-dependencies:
- dependency-name: YamlDotNet
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump Moq from 4.18.2 to 4.18.3

Bumps [Moq](https://github.com/moq/moq4) from 4.18.2 to 4.18.3.
- [Release notes](https://github.com/moq/moq4/releases)
- [Changelog](https://github.com/moq/moq4/blob/main/CHANGELOG.md)
- [Commits](https://github.com/moq/moq4/compare/v4.18.2...v4.18.3)

---
updated-dependencies:
- dependency-name: Moq
... (continued)

10732 of 20257 branches covered (0.0%)

Branch coverage included in aggregate %.

48141 of 48141 new or added lines in 1086 files covered. (100.0%)

30685 of 52388 relevant lines covered (58.57%)

7387.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/Rdmp.Core/Curation/Data/SupportingSQLTable.cs
1
// Copyright (c) The University of Dundee 2018-2019
2
// This file is part of the Research Data Management Platform (RDMP).
3
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>.
6

7
using System;
8
using System.Collections.Generic;
9
using System.Data.Common;
10
using FAnsi.Discovery;
11
using Rdmp.Core.MapsDirectlyToDatabaseTable;
12
using Rdmp.Core.MapsDirectlyToDatabaseTable.Attributes;
13
using Rdmp.Core.Repositories;
14
using Rdmp.Core.ReusableLibraryCode.Annotations;
15
using Rdmp.Core.ReusableLibraryCode.DataAccess;
16
using Rdmp.Core.Ticketing;
17

18
namespace Rdmp.Core.Curation.Data;
19

20
/// <summary>
21
/// Describes an SQL query that can be run to generate useful information for the understanding of a given Catalogue (dataset).  If it is marked as
22
/// Extractable then it will be bundled along with the Catalogue every time it is extracted.  This can be used as an alternative to definining Lookups
23
/// through the Lookup class or to extract other useful administrative data etc to be provided to researchers
24
/// 
25
/// <para>It is VITAL that you do not use this as a method of extracting sensitive/patient data as this data is run as is and is not joined against a cohort
26
/// or anonymised in anyway.</para>
27
/// 
28
/// <para>If the Global flag is set then the SQL will be run and the result provided to every researcher regardless of what datasets they have asked for in
29
/// an extraction, this is useful for large lookups like ICD / SNOMED CT which are likely to be used by many datasets. </para>
30
/// </summary>
31
public class SupportingSQLTable : DatabaseEntity, INamed, ISupportingObject
32
{
33
    /// <summary>
34
    /// The subfolder of extractions in which to put <see cref="Extractable"/> <see cref="SupportingSQLTable"/> when doing project extractions
35
    /// </summary>
36
    public const string ExtractionFolderName = "SupportingDataTables";
37

38
    #region Database Properties
39

40
    private int _catalogue_ID;
41
    private string _description;
42
    private string _name;
43
    private string _sQL;
44
    private bool _extractable;
45
    private int? _externalDatabaseServer_ID;
46
    private string _ticket;
47
    private bool _isGlobal;
48

49
    /// <summary>
50
    /// The dataset the <see cref="SupportingSQLTable"/> helps you to understand
51
    /// </summary>
52
    public int Catalogue_ID
53
    {
54
        get => _catalogue_ID;
214✔
55
        set => SetField(ref _catalogue_ID, value);
40✔
56
    }
57

58
    /// <summary>
59
    /// Human readable description of what the table referenced by <see cref="SQL"/> contains
60
    /// </summary>
61
    public string Description
62
    {
63
        get => _description;
24✔
64
        set => SetField(ref _description, value);
24✔
65
    }
66

67
    /// <inheritdoc/>
68
    [NotNull]
69
    [Unique]
70
    public string Name
71
    {
72
        get => _name;
60✔
73
        set => SetField(ref _name, value);
40✔
74
    }
75

76
    /// <summary>
77
    /// Sql to execute on the server to return the supplemental table that helps with understanding/interpreting <see cref="Catalogue_ID"/>
78
    /// </summary>
79
    public string SQL
80
    {
81
        get => _sQL;
44✔
82
        set => SetField(ref _sQL, value);
28✔
83
    }
84

85
    /// <summary>
86
    /// If true then the query will be executed and the resulting table will be copied to the output directory of project extractions that include the <see cref="Catalogue_ID"/>.
87
    /// 
88
    /// <para>This will fail if the query contains mulitple select statements.  Ensure that there is no identifiable data returned by the query since it will not be linked
89
    /// against the project cohort / anonymised in any way.</para>
90
    /// </summary>
91
    public bool Extractable
92
    {
93
        get => _extractable;
34✔
94
        set => SetField(ref _extractable, value);
28✔
95
    }
96

97
    /// <summary>
98
    /// The server on which the <see cref="SQL"/> should be executed on
99
    /// </summary>
100
    public int? ExternalDatabaseServer_ID
101
    {
102
        get => _externalDatabaseServer_ID;
38✔
103
        set => SetField(ref _externalDatabaseServer_ID, value);
28✔
104
    }
105

106
    /// <summary>
107
    /// <see cref="ITicketingSystem"/> identifier of a ticket for logging time curating / updating etc the table
108
    /// </summary>
109
    public string Ticket
110
    {
111
        get => _ticket;
24✔
112
        set => SetField(ref _ticket, value);
24✔
113
    }
114

115
    /// <summary>
116
    /// If <see cref="Extractable"/>  and <see cref="IsGlobal"/> then the table will be copied to the ouptut directory of all project extractions
117
    /// regardless of whether or not the <see cref="Catalogue_ID"/> dataset is included in the extraction
118
    /// </summary>
119
    public bool IsGlobal
120
    {
121
        get => _isGlobal;
38✔
122
        set => SetField(ref _isGlobal, value);
26✔
123
    }
124

125
    #endregion
126

127
    #region Relationships
128

129
    /// <inheritdoc cref="Catalogue_ID"/>
130
    [NoMappingToDatabase]
131
    public Catalogue Catalogue => Repository.GetObjectByID<Catalogue>(Catalogue_ID);
2✔
132

133
    /// <inheritdoc cref="ExternalDatabaseServer_ID"/>
134
    [NoMappingToDatabase]
135
    public ExternalDatabaseServer ExternalDatabaseServer => ExternalDatabaseServer_ID == null
8✔
136
        ? null
8✔
137
        : Repository.GetObjectByID<ExternalDatabaseServer>((int)ExternalDatabaseServer_ID);
8✔
138

139
    #endregion
140

141
    public SupportingSQLTable()
×
142
    {
143
    }
×
144

145
    /// <summary>
146
    /// Defines a new table that helps in understanding the given dataset <paramref name="parent"/>
147
    /// </summary>
148
    /// <param name="repository"></param>
149
    /// <param name="parent"></param>
150
    /// <param name="name"></param>
151
    public SupportingSQLTable(ICatalogueRepository repository, ICatalogue parent, string name)
24✔
152
    {
153
        repository.InsertAndHydrate(this, new Dictionary<string, object>
24✔
154
        {
24✔
155
            { "Name", name },
24✔
156
            { "Catalogue_ID", parent.ID }
24✔
157
        });
24✔
158
    }
24✔
159

160
    internal SupportingSQLTable(ICatalogueRepository repository, DbDataReader r)
161
        : base(repository, r)
16✔
162
    {
163
        Catalogue_ID = int.Parse(r["Catalogue_ID"].ToString());
16✔
164
        Description = r["Description"] as string;
16✔
165
        Name = r["Name"] as string;
16✔
166
        Extractable = (bool)r["Extractable"];
16✔
167
        IsGlobal = (bool)r["IsGlobal"];
16✔
168
        SQL = r["SQL"] as string;
16✔
169

170
        if (r["ExternalDatabaseServer_ID"] == null || r["ExternalDatabaseServer_ID"] == DBNull.Value)
16✔
171
            ExternalDatabaseServer_ID = null;
12✔
172
        else
173
            ExternalDatabaseServer_ID = Convert.ToInt32(r["ExternalDatabaseServer_ID"]);
4✔
174

175
        Ticket = r["Ticket"] as string;
16✔
176
    }
16✔
177

178
    /// <inheritdoc/>
179
    public override string ToString() => Name;
12✔
180

181
    /// <summary>
182
    /// Returns the decrypted connection string you can use to access the data (fetched from ExternalDatabaseServer_ID - which can be null).  If there is no
183
    /// ExternalDatabaseServer_ID associated with the SupportingSQLTable then a NotSupportedException will be thrown
184
    /// </summary>
185
    /// <returns></returns>
186
    public DiscoveredServer GetServer() =>
187
        ExternalDatabaseServer_ID == null
4!
188
            ? throw new NotSupportedException(
4✔
189
                $"No external database server has been selected for SupportingSQL table called :{ToString()} (ID={ID}).  The SupportingSQLTable currently belongs to Catalogue {Catalogue.Name}")
4✔
190
            : ExternalDatabaseServer.Discover(DataAccessContext.DataExport).Server;
4✔
191
}
192

193
/// <summary>
194
/// Identifies which collection of extractable resources should be returned from the database
195
/// </summary>
196
public enum FetchOptions
197
{
198
    /// <summary>
199
    /// All resources
200
    /// </summary>
201
    AllGlobalsAndAllLocals,
202

203
    /// <summary>
204
    /// Global resources only
205
    /// </summary>
206
    AllGlobals,
207

208
    /// <summary>
209
    /// Non Global resources only
210
    /// </summary>
211
    AllLocals,
212

213
    /// <summary>
214
    /// Global resources only AND only if they are marked Extractable
215
    /// </summary>
216
    ExtractableGlobals,
217

218
    /// <summary>
219
    /// Non Global resources only AND only if they are marked Extractable
220
    /// </summary>
221
    ExtractableLocals,
222

223
    /// <summary>
224
    /// All resources that are marked Extractable
225
    /// </summary>
226
    ExtractableGlobalsAndLocals
227
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc