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

HicServices / RDMP / 6237307473

19 Sep 2023 04:02PM UTC coverage: 57.015% (-0.4%) from 57.44%
6237307473

push

github

web-flow
Feature/rc4 (#1570)

* Syntax tidying
* Dependency updates
* Event handling singletons (ThrowImmediately and co)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: James A Sutherland <>
Co-authored-by: James Friel <jfriel001@dundee.ac.uk>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

10734 of 20259 branches covered (0.0%)

Branch coverage included in aggregate %.

5922 of 5922 new or added lines in 565 files covered. (100.0%)

30687 of 52390 relevant lines covered (58.57%)

7361.8 hits per line

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

75.47
/Rdmp.Core/QueryBuilding/Options/AggregateBuilderBasicOptions.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.Linq;
9
using Rdmp.Core.Curation.Data;
10
using Rdmp.Core.Curation.Data.Aggregation;
11
using Rdmp.Core.MapsDirectlyToDatabaseTable;
12

13
namespace Rdmp.Core.QueryBuilding.Options;
14

15
/// <summary>
16
/// Describes what parts of the GROUP BY statement are allowed for <see cref="AggregateConfiguration"/> that are running in 'graph mode'
17
/// </summary>
18
public class AggregateBuilderBasicOptions : IAggregateBuilderOptions
19
{
20
    /// <inheritdoc/>
21
    public string GetTitleTextPrefix(AggregateConfiguration aggregate) =>
22
        aggregate.IsExtractable ? "Extractable 'Group By' Aggregate:" : "'Group By' Aggregate:";
×
23

24
    /// <inheritdoc/>
25
    public IColumn[] GetAvailableSELECTColumns(AggregateConfiguration aggregate)
26
    {
27
        var existingDimensions = aggregate.AggregateDimensions.Select(d => d.ExtractionInformation).ToArray();
22✔
28

29
        return aggregate.Catalogue
10✔
30
            .GetAllExtractionInformation(ExtractionCategory.Any) //all columns of any extraction category
10✔
31
            .Except(existingDimensions) //except those that have already been added
10✔
32
            .Where(e => !e
8✔
33
                .IsExtractionIdentifier) //don't advertise IsExtractionIdentifier columns for use in basic aggregates
8✔
34
            .Cast<IColumn>()
10✔
35
            .ToArray();
10✔
36
    }
37

38
    /// <inheritdoc/>
39
    public IColumn[] GetAvailableWHEREColumns(AggregateConfiguration aggregate) =>
40
        //for this basic case the WHERE columns can be anything
41
        aggregate.Catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Cast<IColumn>().ToArray();
×
42

43
    /// <inheritdoc/>
44
    public bool ShouldBeEnabled(AggregateEditorSection section, AggregateConfiguration aggregate)
45
    {
46
        return section switch
44!
47
        {
44✔
48
            AggregateEditorSection.Extractable => CanMakeExtractable(aggregate),
10✔
49
            AggregateEditorSection.TOPX =>
44✔
50
                //can only Top X if we have a pivot (top x applies to the selection of the pivot values) or if we have nothing (no axis / pivot).  This rules out axis only queries
44✔
51
                aggregate.PivotOnDimensionID != null || aggregate.GetAxisIfAny() == null,
10✔
52
            AggregateEditorSection.PIVOT => aggregate.GetAxisIfAny() != null ||
12!
53
                                            aggregate.AggregateDimensions.Length ==
12✔
54
                                            2 //can only pivot if there is an axis or exactly 2 dimensions (+ count)
12✔
55
            ,
44✔
56
            AggregateEditorSection.AXIS => true,
12✔
57
            _ => throw new ArgumentOutOfRangeException(nameof(section))
×
58
        };
44✔
59
    }
60

61
    /// <inheritdoc/>
62
    public IMapsDirectlyToDatabaseTable[] GetAvailableJoinables(AggregateConfiguration aggregate)
63
    {
64
        var availableTables = aggregate.Catalogue.GetAllExtractionInformation(ExtractionCategory.Any)
10✔
65
            .Select(e => e.ColumnInfo?.TableInfo)
20!
66
            .Where(t => t != null)
20✔
67
            .Distinct();
10✔
68

69
        var implicitJoins =
10✔
70
            aggregate.ForcedJoins.Union(
10✔
71
                aggregate.AggregateDimensions.Select(d => d.ExtractionInformation.ColumnInfo.TableInfo).Distinct());
22✔
72

73
        //return all TableInfos that are not already force joined
74
        return availableTables.Except(implicitJoins).Cast<IMapsDirectlyToDatabaseTable>().ToArray();
10✔
75
    }
76

77
    private static bool CanMakeExtractable(AggregateConfiguration aggregate)
78
    {
79
        //if it has any extraction identifiers then it cannot be extractable!
80
        if (aggregate.AggregateDimensions.Any(d => d.IsExtractionIdentifier))
22!
81
        {
82
            aggregate.IsExtractable = false;
×
83
            aggregate.SaveToDatabase();
×
84
            return false;
×
85
        }
86

87
        return true;
10✔
88
    }
89

90
    /// <inheritdoc/>
91
    public ISqlParameter[] GetAllParameters(AggregateConfiguration aggregate) => aggregate.GetAllParameters();
×
92

93
    /// <inheritdoc/>
94
    public CountColumnRequirement GetCountColumnRequirement(AggregateConfiguration aggregate) =>
95
        CountColumnRequirement.MustHaveOne;
20✔
96
}
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