• 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

0.0
/Rdmp.Core/DataViewing/ViewTableInfoExtractUICollection.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.Linq;
10
using FAnsi.Discovery.QuerySyntax;
11
using Rdmp.Core.Curation.Data;
12
using Rdmp.Core.Curation.Data.Dashboarding;
13
using Rdmp.Core.Curation.Data.Spontaneous;
14
using Rdmp.Core.QueryBuilding;
15
using Rdmp.Core.Repositories;
16
using Rdmp.Core.ReusableLibraryCode.DataAccess;
17

18
namespace Rdmp.Core.DataViewing;
19

20
/// <summary>
21
/// Builds a query to fetch data from a <see cref="TableInfo"/>
22
/// </summary>
23
public class ViewTableInfoExtractUICollection : PersistableObjectCollection, IViewSQLAndResultsCollection
24
{
25
    public ViewType ViewType { get; private set; }
×
26
    public bool DisableRun => false;
×
27

28
    /// <summary>
29
    /// for persistence, do not use
30
    /// </summary>
31
    public ViewTableInfoExtractUICollection()
×
32
    {
33
    }
×
34

35
    public ViewTableInfoExtractUICollection(ITableInfo t, ViewType viewType, IFilter filter = null)
36
        : this()
×
37
    {
38
        DatabaseObjects.Add(t);
×
39

40
        if (filter != null)
×
41
            DatabaseObjects.Add(filter);
×
42
        ViewType = viewType;
×
43
    }
×
44

45
    public override string SaveExtraText() => PersistStringHelper.SaveDictionaryToString(new Dictionary<string, string>
×
46
        { { "ViewType", ViewType.ToString() } });
×
47

48
    public override void LoadExtraText(string s)
49
    {
50
        var value = PersistStringHelper.GetValueIfExistsFromPersistString("ViewType", s);
×
51
        ViewType = (ViewType)Enum.Parse(typeof(ViewType), value);
×
52
    }
×
53

54
    public object GetDataObject()
55
    {
56
        return DatabaseObjects.Single(o => o is ColumnInfo or Curation.Data.TableInfo);
×
57
    }
58

59
    public IFilter GetFilterIfAny()
60
    {
61
        return (IFilter)DatabaseObjects.SingleOrDefault(o => o is IFilter);
×
62
    }
63

64
    public IEnumerable<DatabaseEntity> GetToolStripObjects()
65
    {
66
        if (GetFilterIfAny() is ConcreteFilter filter)
×
67
            yield return filter;
×
68
    }
×
69

70
    public IDataAccessPoint GetDataAccessPoint() => TableInfo;
×
71

72
    public string GetSql()
73
    {
74
        var qb = new QueryBuilder(null, null);
×
75

76
        if (ViewType == ViewType.TOP_100)
×
77
            qb.TopX = 100;
×
78

79
        var memoryRepository = new MemoryCatalogueRepository();
×
80

81
        qb.AddColumnRange(TableInfo.ColumnInfos.Select(c => new ColumnInfoToIColumn(memoryRepository, c)).ToArray());
×
82

83
        var filter = GetFilterIfAny();
×
84
        if (filter != null)
×
85
            qb.RootFilterContainer = new SpontaneouslyInventedFilterContainer(memoryRepository, null, new[] { filter },
×
86
                FilterContainerOperation.AND);
×
87

88
        var sql = qb.SQL;
×
89

90
        return ViewType == ViewType.Aggregate
×
91
            ? throw new NotSupportedException("ViewType.Aggregate can only be applied to ColumnInfos not TableInfos")
×
92
            : sql;
×
93
    }
94

95
    public string GetTabName() => $"{TableInfo}({ViewType})";
×
96

97
    public void AdjustAutocomplete(IAutoCompleteProvider autoComplete)
98
    {
99
        autoComplete.Add(TableInfo);
×
100
    }
×
101

102
    public TableInfo TableInfo => DatabaseObjects.OfType<TableInfo>().SingleOrDefault();
×
103

104
    public IQuerySyntaxHelper GetQuerySyntaxHelper()
105
    {
106
        var t = TableInfo;
×
107
        return t?.GetQuerySyntaxHelper();
×
108
    }
109
}
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