• 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

83.02
/Rdmp.Core/DataExport/Checks/ExtractionConfigurationChecker.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.IO;
8
using System.Linq;
9
using Rdmp.Core.CommandExecution;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.DataExport.Data;
12
using Rdmp.Core.DataExport.DataExtraction;
13
using Rdmp.Core.Repositories;
14
using Rdmp.Core.ReusableLibraryCode.Checks;
15

16
namespace Rdmp.Core.DataExport.Checks;
17

18
/// <summary>
19
/// Checks <see cref="ExtractionConfiguration"/> to ensure they are in a valid state for execution (have a cohort, linkable patient columns etc).  Optionally also checks
20
/// each dataset in the configuration with a <see cref="SelectedDataSetsChecker"/>
21
/// </summary>
22
public class ExtractionConfigurationChecker : ICheckable
23
{
24
    private IExtractionConfiguration _config;
25
    private IBasicActivateItems _activator;
26

27
    /// <summary>
28
    /// True to fetch all <see cref="ISelectedDataSets"/> and check with <see cref="SelectedDataSetsChecker"/>
29
    /// </summary>
30
    public bool CheckDatasets { get; set; }
12✔
31

32
    /// <summary>
33
    /// True to also check all globals with a <see cref="GlobalExtractionChecker"/>
34
    /// </summary>
35
    public bool CheckGlobals { get; set; }
2✔
36

37
    /// <summary>
38
    /// Prepares checking of the given <paramref name="config"/>
39
    /// </summary>
40
    /// <param name="activator"></param>
41
    /// <param name="config"></param>
42
    public ExtractionConfigurationChecker(IBasicActivateItems activator, IExtractionConfiguration config)
10✔
43
    {
44
        _config = config;
10✔
45
        _activator = activator;
10✔
46
    }
10✔
47

48
    /// <summary>
49
    /// Checks that the configuration is in a valid state.  Supports both released (frozen) <see cref="ExtractionConfiguration"/> and unreleased ones.
50
    /// </summary>
51
    /// <param name="notifier"></param>
52
    public void Check(ICheckNotifier notifier)
53
    {
54
        if (_config.IsReleased)
10✔
55
            CheckReleaseConfiguration(notifier);
4✔
56
        else
57
            CheckInProgressConfiguration(notifier);
6✔
58
    }
2✔
59

60
    private void CheckReleaseConfiguration(ICheckNotifier notifier)
61
    {
62
        var projectDirectory = new DirectoryInfo(_config.Project.ExtractionDirectory);
4✔
63

64
        notifier.OnCheckPerformed(new CheckEventArgs($"Found Frozen/Released configuration '{_config}'",
4✔
65
            CheckResult.Success));
4✔
66

67
        foreach (var directoryInfo in projectDirectory.GetDirectories(
16✔
68
                     $"{ExtractionDirectory.GetExtractionDirectoryPrefix(_config)}*").ToArray())
4✔
69
            if (DirectoryIsEmpty(directoryInfo, out var firstFileFound))
4✔
70
            {
71
                var deleteIt =
2✔
72
                    notifier.OnCheckPerformed(
2✔
73
                        new CheckEventArgs(
2✔
74
                            $"Found empty folder {directoryInfo.Name} which is left over extracted folder after data release",
2✔
75
                            CheckResult.Warning, null,
2✔
76
                            "Delete empty folder"));
2✔
77

78
                if (deleteIt)
2✔
79
                    directoryInfo.Delete(true);
2✔
80
            }
81
            else
82
            {
83
                notifier.OnCheckPerformed(
2✔
84
                    new CheckEventArgs(
2✔
85
                        $"Found non-empty folder {directoryInfo.Name} which is left over extracted folder after data release (First file found was '{firstFileFound}' but there may be others)",
2✔
86
                        CheckResult.Fail));
2✔
87
            }
88
    }
4✔
89

90
    private bool DirectoryIsEmpty(DirectoryInfo d, out string firstFileFound)
91
    {
92
        var found = d.GetFiles().FirstOrDefault();
12✔
93
        if (found != null)
12✔
94
        {
95
            firstFileFound = found.FullName;
2✔
96
            return false;
2✔
97
        }
98

99
        foreach (var directory in d.GetDirectories())
32✔
100
            if (!DirectoryIsEmpty(directory, out firstFileFound))
8✔
101
                return false;
4✔
102

103
        firstFileFound = null;
6✔
104
        return true;
6✔
105
    }
106

107
    private void CheckInProgressConfiguration(ICheckNotifier notifier)
108
    {
109
        var repo = (IDataExportRepository)_config.Repository;
6✔
110
        notifier.OnCheckPerformed(new CheckEventArgs($"Found configuration '{_config}'", CheckResult.Success));
6✔
111

112
        var datasets = _config.GetAllExtractableDataSets().ToArray();
6✔
113

114
        foreach (ExtractableDataSet dataSet in datasets)
18✔
115
            if (dataSet.DisableExtraction)
4✔
116
                notifier.OnCheckPerformed(
2✔
117
                    new CheckEventArgs(
2✔
118
                        $"Dataset {dataSet} is set to DisableExtraction=true, probably someone doesn't want you extracting this dataset at the moment",
2✔
119
                        CheckResult.Fail));
2✔
120

121
        if (!datasets.Any())
4✔
122
            notifier.OnCheckPerformed(
2✔
123
                new CheckEventArgs(
2✔
124
                    $"There are no datasets selected for open configuration '{_config}'",
2✔
125
                    CheckResult.Fail));
2✔
126

127
        if (_config.Cohort_ID == null)
2!
128
        {
129
            notifier.OnCheckPerformed(
×
130
                new CheckEventArgs(
×
131
                    $"Open configuration '{_config}' does not have a cohort yet",
×
132
                    CheckResult.Fail));
×
133
            return;
×
134
        }
135

136
        //make sure that its cohort is retrievable
137
        var cohort = repo.GetObjectByID<ExtractableCohort>((int)_config.Cohort_ID);
2✔
138
        if (cohort.IsDeprecated)
2!
139
            notifier.OnCheckPerformed(
×
140
                new CheckEventArgs(
×
141
                    $"Cohort '{cohort}' is marked IsDeprecated",
×
142
                    CheckResult.Fail));
×
143

144
        if (CheckDatasets)
2✔
145
            foreach (var s in _config.SelectedDataSets)
8✔
146
                new SelectedDataSetsChecker(_activator, s).Check(notifier);
2✔
147

148
        //globals
149
        if (CheckGlobals)
2!
150
            if (datasets.Any())
×
151
                foreach (var table in _config.GetGlobals().OfType<SupportingSQLTable>())
×
152
                    new SupportingSQLTableChecker(table).Check(notifier);
×
153
    }
2✔
154
}
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