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

HicServices / RDMP / 26566925905

28 May 2026 09:37AM UTC coverage: 57.023% (-0.08%) from 57.101%
26566925905

push

github

JFriel
Merge branch 'bugfix/cohort-commit-issue' of https://github.com/HicServices/RDMP into bugfix/cohort-commit-issue

11562 of 21813 branches covered (53.01%)

Branch coverage included in aggregate %.

32688 of 55787 relevant lines covered (58.59%)

18057.84 hits per line

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

53.19
/Rdmp.Core/DataViewing/ViewCatalogueDataCollection.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.Collections.Generic;
8
using System.Linq;
9
using FAnsi.Discovery.QuerySyntax;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.Curation.Data.Dashboarding;
12
using Rdmp.Core.Curation.Data.Spontaneous;
13
using Rdmp.Core.QueryBuilding;
14
using Rdmp.Core.Repositories;
15
using Rdmp.Core.ReusableLibraryCode.DataAccess;
16

17
namespace Rdmp.Core.DataViewing;
18

19
/// <summary>
20
/// Collection for generating SQL around the extractable columns of a catalogue
21
/// </summary>
22
public class ViewCatalogueDataCollection : PersistableObjectCollection, IViewSQLAndResultsCollection
23
{
24
    private QueryBuilder builder;
25

26
    public Catalogue Catalogue => DatabaseObjects.OfType<Catalogue>().FirstOrDefault();
4✔
27

28
    public IFilter[] Filters => DatabaseObjects.OfType<IFilter>().ToArray();
2✔
29
    public bool DisableRun => false;
×
30

31
    public ExtractionInformation[] ExtractionInformations => DatabaseObjects.OfType<ExtractionInformation>().ToArray();
2✔
32

33
    /// <summary>
34
    /// The number of records to fetch (or null to fetch all records)
35
    /// </summary>
36
    public int? TopX { get; set; }
2✔
37

38
    public ViewCatalogueDataCollection(Catalogue catalogue)
2✔
39
    {
40
        DatabaseObjects.Add(catalogue);
2✔
41
    }
2✔
42

43
    /// <summary>
44
    /// Persistence constructor
45
    /// </summary>
46
    public ViewCatalogueDataCollection()
×
47
    {
48
    }
×
49

50
    private void BuildBuilder()
51
    {
52
        if (builder != null)
2!
53
            return;
×
54

55
        builder = new QueryBuilder(null, null);
2✔
56

57
        if (TopX.HasValue)
2!
58
            builder.TopX = TopX.Value;
×
59

60
        var cols = ExtractionInformations;
2✔
61

62
        // if there are no explicit columns use all
63
        if (!cols.Any())
2✔
64
            cols =
2✔
65
                Catalogue.GetAllExtractionInformation(ExtractionCategory.Core)
2✔
66
                    .Union(Catalogue.GetAllExtractionInformation(ExtractionCategory.ProjectSpecific))
2✔
67
                    .ToArray();
2✔
68

69
        builder.AddColumnRange(cols);
2✔
70

71
        builder.RootFilterContainer = new SpontaneouslyInventedFilterContainer(new MemoryCatalogueRepository(), null,
2✔
72
            Filters, FilterContainerOperation.AND);
2✔
73
        builder.RegenerateSQL();
2✔
74
    }
×
75

76
    public void AdjustAutocomplete(IAutoCompleteProvider autoComplete)
77
    {
78
        BuildBuilder();
×
79

80
        foreach (var t in builder.TablesUsedInQuery)
×
81
            autoComplete.Add(t);
×
82
    }
×
83

84
    public IDataAccessPoint GetDataAccessPoint()
85
    {
86
        BuildBuilder();
×
87
        return builder.TablesUsedInQuery.FirstOrDefault();
×
88
    }
89

90
    public IQuerySyntaxHelper GetQuerySyntaxHelper()
91
    {
92
        BuildBuilder();
×
93
        return builder.QuerySyntaxHelper;
×
94
    }
95

96
    public string GetSql()
97
    {
98
        BuildBuilder();
2✔
99
        return builder.SQL;
×
100
    }
101

102
    public string GetTabName() => Catalogue.Name;
×
103

104
    public IEnumerable<DatabaseEntity> GetToolStripObjects()
105
    {
106
        yield return Catalogue;
×
107
    }
×
108
}
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