• 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

87.1
/Rdmp.Core/DataExport/Data/DeployedExtractionFilter.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 System.Linq;
11
using Rdmp.Core.Curation.Checks;
12
using Rdmp.Core.Curation.Data;
13
using Rdmp.Core.Curation.FilterImporting.Construction;
14
using Rdmp.Core.MapsDirectlyToDatabaseTable;
15
using Rdmp.Core.MapsDirectlyToDatabaseTable.Attributes;
16
using Rdmp.Core.Repositories;
17
using Rdmp.Core.ReusableLibraryCode.Checks;
18

19
namespace Rdmp.Core.DataExport.Data;
20

21
/// <summary>
22
/// Sometimes it is necessary to restrict which records are extracted for a given ExtractionConfiguration beyond the linkage against a cohort.  For example you might want to extract
23
/// 'only paracetamol prescriptions' for your cohort rather than the entire Prescribing dataset.  This is achieved by using a DeployedExtractionFilter.  DeployedExtractionFilters are
24
/// curated pieces of WHERE SQL with a name and description.  These can either be written bespoke for your extract or copied from a master ExtractionFilter in the Catalogue database.
25
/// In general if a filter concept is reusable and useful across multiple projects / over time then you should create it in the Catalogue database as an ExtractionFilter and then
26
/// import a copy into your ExtractionConfiguration each time you need it (or mark it as IsMandatory if it should always be used in data extraction of that Catalogue).
27
/// 
28
/// <para>When you import a master filter into your ExtractionConfiguration a copy of the WHERE SQL, any
29
/// parameters and the name and description will be made as a DeployedExtractionFilter which will also contain a reference back to the original (ClonedFromExtractionFilter_ID).  This
30
/// allows you to ensure consistency over time and gives you a central location (the ExtractionFilter) to fix errors in the Filter implementation etc.  </para>
31
/// 
32
/// </summary>
33
public class DeployedExtractionFilter : ConcreteFilter
34
{
35
    #region Database Properties
36

37
    private int? _clonedFromExtractionFilterID;
38
    private int? _filterContainerID;
39

40
    /// <inheritdoc/>
41
    public override int? ClonedFromExtractionFilter_ID
42
    {
43
        get => _clonedFromExtractionFilterID;
74✔
44
        set => SetField(ref _clonedFromExtractionFilterID, value);
104✔
45
    }
46

47
    /// <inheritdoc/>
48
    [Relationship(typeof(FilterContainer), RelationshipType.SharedObject)]
49
    public override int? FilterContainer_ID
50
    {
51
        get => _filterContainerID;
386✔
52
        set => SetField(ref _filterContainerID, value);
140✔
53
    }
54

55
    #endregion
56

57
    #region Relationships
58

59
    /// <summary>
60
    /// Returns all parameters declared against this filter (does not include other parameters in scope e.g. globals)
61
    /// </summary>
62
    [NoMappingToDatabase]
63
    public DeployedExtractionFilterParameter[] ExtractionFilterParameters => Repository
48✔
64
        .GetAllObjectsWhere<DeployedExtractionFilterParameter>("ExtractionFilter_ID", ID).ToArray();
48✔
65

66
    /// <inheritdoc/>
67
    [NoMappingToDatabase]
68
    public override IContainer FilterContainer => FilterContainer_ID.HasValue
8!
69
        ? Repository.GetObjectByID<FilterContainer>(FilterContainer_ID.Value)
8✔
70
        : null;
8✔
71

72
    #endregion
73

74
    /// <inheritdoc/>
75
    public override ColumnInfo GetColumnInfoIfExists() => null;
26✔
76

77
    /// <inheritdoc/>
78
    public override IFilterFactory GetFilterFactory() =>
79
        new DeployedExtractionFilterFactory((IDataExportRepository)Repository);
8✔
80

81
    /// <inheritdoc/>
82
    public override Catalogue GetCatalogue()
83
    {
84
        var ds = GetDataset().ExtractableDataSet;
16✔
85
        try
86
        {
87
            return (Catalogue)ds.Catalogue;
16✔
88
        }
89
        catch (Exception)
×
90
        {
91
            //could be that the catalogue has been deleted
92
            return null;
×
93
        }
94
    }
16✔
95

96
    /// <inheritdoc/>
97
    public override ISqlParameter[] GetAllParameters() => ExtractionFilterParameters.Cast<ISqlParameter>().ToArray();
42✔
98

99
    public DeployedExtractionFilter()
×
100
    {
101
    }
×
102

103
    /// <summary>
104
    /// Creates a new empty WHERE filter in the given <paramref name="container"/> that will be used when
105
    /// extracting the dataset.
106
    /// 
107
    /// <para>This object is created into the data export metadata database</para>
108
    /// </summary>
109
    /// <param name="repository"></param>
110
    /// <param name="name"></param>
111
    /// <param name="container"></param>
112
    public DeployedExtractionFilter(IDataExportRepository repository, string name, FilterContainer container)
36✔
113
    {
114
        Repository = repository;
36✔
115
        Repository.InsertAndHydrate(this, new Dictionary<string, object>
36!
116
        {
36✔
117
            { "Name", name != null ? (object)name : DBNull.Value },
36✔
118
            { "FilterContainer_ID", container != null ? (object)container.ID : DBNull.Value }
36✔
119
        });
36✔
120
    }
36✔
121

122
    /// <summary>
123
    /// Read an existing WHERE filter out of the database
124
    /// </summary>
125
    /// <param name="repository"></param>
126
    /// <param name="r"></param>
127
    internal DeployedExtractionFilter(IDataExportRepository repository, DbDataReader r)
128
        : base(repository, r)
86✔
129
    {
130
        WhereSQL = r["WhereSQL"] as string;
86✔
131
        Description = r["Description"] as string;
86✔
132
        Name = r["Name"] as string;
86✔
133
        IsMandatory = (bool)r["IsMandatory"];
86✔
134

135
        if (r["FilterContainer_ID"] != null && !string.IsNullOrWhiteSpace(r["FilterContainer_ID"].ToString()))
86✔
136
            FilterContainer_ID = int.Parse(r["FilterContainer_ID"].ToString());
78✔
137
        else
138
            FilterContainer_ID = null;
8✔
139

140
        ClonedFromExtractionFilter_ID = ObjectToNullableInt(r["ClonedFromExtractionFilter_ID"]);
86✔
141
    }
86✔
142

143
    /// <summary>
144
    /// Returns Name of filters
145
    /// </summary>
146
    /// <returns></returns>
147
    public override string ToString() => Name;
10✔
148

149

150
    /// <summary>
151
    /// Checks the filter is properly defined (e.g. not blank).
152
    /// </summary>
153
    /// <param name="notifier"></param>
154
    public override void Check(ICheckNotifier notifier)
155
    {
156
        base.Check(notifier);
10✔
157

158
        var checker = new ClonedFilterChecker(this, ClonedFromExtractionFilter_ID,
10✔
159
            ((IDataExportRepository)Repository).CatalogueRepository);
10✔
160
        checker.Check(notifier);
10✔
161
    }
10✔
162

163
    /// <summary>
164
    /// Returns the configuration and dataset (<see cref="ISelectedDataSets"/>) in which the filter is declared.  This involves traversing
165
    /// up any nested <see cref="FilterContainer"/>s to the root.
166
    /// 
167
    /// <para>Returns null if the filter is an orphan (not in a container or part of an orphan container tree)</para>
168
    /// </summary>
169
    /// <returns></returns>
170
    public SelectedDataSets GetDataset()
171
    {
172
        if (FilterContainer_ID == null)
16!
173
            return null;
×
174

175
        var container = Repository.GetObjectByID<FilterContainer>(FilterContainer_ID.Value);
16✔
176
        return container.GetSelectedDataSetsRecursively();
16✔
177
    }
178

179
    public DeployedExtractionFilter ShallowClone(FilterContainer into)
180
    {
181
        var clone = new DeployedExtractionFilter(DataExportRepository, Name, into);
4✔
182
        CopyShallowValuesTo(clone);
4✔
183
        return clone;
4✔
184
    }
185
}
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

© 2026 Coveralls, Inc