• 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

73.91
/Rdmp.Core/DataExport/Data/ExtractableDataSet.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.Data;
12
using Rdmp.Core.MapsDirectlyToDatabaseTable;
13
using Rdmp.Core.MapsDirectlyToDatabaseTable.Injection;
14
using Rdmp.Core.Repositories;
15

16
namespace Rdmp.Core.DataExport.Data;
17

18
/// <inheritdoc cref="IExtractableDataSet"/>
19
public class ExtractableDataSet : DatabaseEntity, IExtractableDataSet, IInjectKnown<ICatalogue>
20
{
21
    #region Database Properties
22

23
    private int _catalogue_ID;
24
    private bool _disableExtraction;
25
    private int? _project_ID;
26

27
    /// <inheritdoc/>
28
    public int Catalogue_ID
29
    {
30
        get => _catalogue_ID;
2,032✔
31
        set
32
        {
33
            ClearAllInjections();
1,008✔
34
            SetField(ref _catalogue_ID, value);
1,008✔
35
        }
1,008✔
36
    }
37

38
    /// <inheritdoc/>
39
    public bool DisableExtraction
40
    {
41
        get => _disableExtraction;
306✔
42
        set => SetField(ref _disableExtraction, value);
1,010✔
43
    }
44

45

46
    /// <inheritdoc/>
47
    public int? Project_ID
48
    {
49
        get => _project_ID;
1,755✔
50
        set => SetField(ref _project_ID, value);
860✔
51
    }
52

53
    #endregion
54

55
    #region Relationships
56

57
    /// <summary>
58
    /// Returns all <see cref="IExtractionConfiguration"/> in which this dataset is one of the extracted datasets
59
    /// </summary>
60
    [NoMappingToDatabase]
61
    public IExtractionConfiguration[] ExtractionConfigurations
62
    {
63
        get
64
        {
65
            return
2✔
66
                Repository.GetAllObjectsWithParent<SelectedDataSets>(this)
2✔
67
                    .Select(sds => sds.ExtractionConfiguration)
×
68
                    .ToArray();
2✔
69
        }
70
    }
71

72
    /// <inheritdoc/>
73
    [NoMappingToDatabase]
74
    public ICatalogue Catalogue => _catalogue.Value;
2,730✔
75

76
    #endregion
77

78

79
    public ExtractableDataSet()
2✔
80
    {
81
        ClearAllInjections();
2✔
82
    }
2✔
83

84
    /// <summary>
85
    /// Defines that the given Catalogue is extractable to researchers as a data set, this is stored in the DataExport database
86
    /// </summary>
87
    /// <returns></returns>
88
    public ExtractableDataSet(IDataExportRepository repository, ICatalogue catalogue, bool disableExtraction = false)
352✔
89
    {
90
        Repository = repository;
352✔
91
        Repository.InsertAndHydrate(this, new Dictionary<string, object>
352✔
92
        {
352✔
93
            { "DisableExtraction", disableExtraction },
352✔
94
            { "Catalogue_ID", catalogue.ID }
352✔
95
        });
352✔
96

97
        ClearAllInjections();
352✔
98
        InjectKnown(catalogue);
352✔
99
    }
352✔
100

101
    internal ExtractableDataSet(IDataExportRepository repository, DbDataReader r)
102
        : base(repository, r)
646✔
103
    {
104
        Catalogue_ID = Convert.ToInt32(r["Catalogue_ID"]);
646✔
105
        DisableExtraction = (bool)r["DisableExtraction"];
646✔
106
        Project_ID = ObjectToNullableInt(r["Project_ID"]);
646✔
107

108
        ClearAllInjections();
646✔
109
    }
646✔
110

111
    /// <inheritdoc/>
112
    [NoMappingToDatabase]
113
    public bool IsCatalogueDeprecated => Catalogue == null || Catalogue.IsDeprecated;
10!
114

115
    /// <summary>
116
    /// Returns the <see cref="ICatalogue"/> behind this dataset's Name or a string describing the object state if the Catalogue is unreachable.
117
    /// </summary>
118
    /// <returns></returns>
119
    public override string ToString()
120
    {
121
        if (Catalogue == null)
708!
122
            return $"DELETED CATALOGUE {Catalogue_ID}";
×
123

124
        //only bother refreshing Catalogue details if we will be able to get a legit catalogue name
125
        return Catalogue.IsDeprecated ? $"DEPRECATED CATALOGUE {Catalogue.Name}" : Catalogue.Name;
708!
126
    }
127

128
    #region Stuff for updating our internal database records
129

130
    /// <summary>
131
    /// Deletes the dataset, this will make the <see cref="ICatalogue"/> non extractable.  This operation fails if
132
    /// the dataset is part of any <see cref="ExtractionConfigurations"/>.
133
    /// </summary>
134
    public override void DeleteInDatabase()
135
    {
136
        try
137
        {
138
            Repository.DeleteFromDatabase(this);
54✔
139
        }
54✔
140
        catch (Exception e)
×
141
        {
142
            if (e.Message.Contains("FK_SelectedDataSets_ExtractableDataSet"))
×
143
                throw new Exception(
×
144
                    $"Cannot delete {this} because it is in use by the following configurations :{Environment.NewLine}{string.Join(Environment.NewLine, ExtractionConfigurations.Select(c => $"{c.Name}({c.Project})"))}",
×
145
                    e);
×
146
            throw;
×
147
        }
148
    }
54✔
149

150
    #endregion
151

152
    /// <summary>
153
    /// Returns an object indicating whether the dataset is project specific or not
154
    /// </summary>
155
    /// <returns></returns>
156
    public CatalogueExtractabilityStatus GetCatalogueExtractabilityStatus() => new(true, Project_ID != null);
398✔
157

158
    private Lazy<ICatalogue> _catalogue;
159

160
    /// <inheritdoc/>
161
    public void InjectKnown(ICatalogue instance)
162
    {
163
        if (instance.ID != Catalogue_ID)
594!
164
            throw new ArgumentOutOfRangeException(nameof(instance),
×
165
                $"You told us our Catalogue was '{instance}' but its ID didn't match so that is NOT our Catalogue");
×
166
        _catalogue = new Lazy<ICatalogue>(instance);
594✔
167
    }
594✔
168

169
    /// <inheritdoc/>
170
    public void ClearAllInjections()
171
    {
172
        _catalogue = new Lazy<ICatalogue>(FetchCatalogue);
2,024✔
173
    }
2,024✔
174

175
    private ICatalogue FetchCatalogue()
176
    {
177
        try
178
        {
179
            var cata = ((IDataExportRepository)Repository).CatalogueRepository.GetObjectByID<Catalogue>(Catalogue_ID);
156✔
180
            cata.InjectKnown(GetCatalogueExtractabilityStatus());
156✔
181
            return cata;
156✔
182
        }
183
        catch (KeyNotFoundException)
×
184
        {
185
            //Catalogue has been deleted!
186
            return null;
×
187
        }
188
    }
156✔
189
}
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