• 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

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandViewFilterMatchData.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.IO;
9
using System.Linq;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.DataViewing;
12
using Rdmp.Core.Icons.IconProvision;
13
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
14
using SixLabors.ImageSharp;
15
using SixLabors.ImageSharp.PixelFormats;
16

17
namespace Rdmp.Core.CommandExecution.AtomicCommands;
18

19
public class ExecuteCommandViewFilterMatchData : ExecuteCommandViewDataBase, IAtomicCommand
20
{
21
    private readonly IFilter _filter;
22
    private readonly IContainer _container;
23

24
    private readonly ViewType _viewType;
25
    private ColumnInfo _columnInfo;
26
    private ColumnInfo[] _candidates;
27

28
    /// <summary>
29
    /// Views an extract of data from a column that matches a given <paramref name="filter"/>
30
    /// </summary>
31
    /// <param name="activator"></param>
32
    /// <param name="filter"></param>
33
    /// <param name="viewType"></param>
34
    /// <param name="columnName"></param>
35
    /// <param name="toFile"></param>
36
    public ExecuteCommandViewFilterMatchData(IBasicActivateItems activator,
37
        [DemandsInitialization("The filter you want to view matching data on (e.g. an AggregateFilter)")]
38
        IFilter filter,
39
        [DemandsInitialization("What kind of data do you want to fetch")]
40
        ViewType viewType = ViewType.TOP_100,
41
        [DemandsInitialization(
42
            "If filter is not implicitly tied to a specific column, pass the name of the column for whom you want to view data.")]
43
        string columnName = null,
44
        [DemandsInitialization(ToFileDescription)]
45
        FileInfo toFile = null) : this(activator, viewType, toFile)
×
46
    {
47
        _filter = filter;
×
48

49
        if (!string.IsNullOrWhiteSpace(columnName))
×
50
        {
51
            var c = filter.GetCatalogue();
×
52
            var candidates = GetCandidates(c);
×
53

54
            // match on exact name?
55
            _columnInfo = candidates.FirstOrDefault(c =>
×
56
                c.GetRuntimeName().Equals(columnName, StringComparison.CurrentCultureIgnoreCase));
×
57
            if (_columnInfo == null)
×
58
                throw new Exception($"Could not find a ColumnInfo called '{columnName}' in Catalogue '{c}'");
×
59
        }
60
        else
61
        {
62
            _columnInfo = filter.GetColumnInfoIfExists();
×
63

64
            //there is a single column associated with the filter?
65
            if (_columnInfo != null)
×
66
                return;
×
67
        }
68

69
        // there is no single column associated with the filter so get user to pick one of them
70
        PopulateCandidates(filter.GetCatalogue(), filter);
×
71
    }
×
72

73
    public ExecuteCommandViewFilterMatchData(IBasicActivateItems activator, IContainer container,
74
        ViewType viewType = ViewType.TOP_100) : this(activator, viewType, null)
×
75
    {
76
        _container = container;
×
77

78
        PopulateCandidates(container.GetCatalogueIfAny(), container);
×
79
    }
×
80

81
    private void PopulateCandidates(Catalogue catalogue, object rootObj)
82
    {
83
        _candidates = GetCandidates(catalogue);
×
84

85
        if (!_candidates.Any())
×
86
            SetImpossible($"No ColumnInfo is associated with '{rootObj}'");
×
87
    }
×
88

89
    private ColumnInfo[] GetCandidates(Catalogue catalogue)
90
    {
91
        if (catalogue == null)
×
92
        {
93
            SetImpossible("Filter has no Catalogue");
×
94
            return null;
×
95
        }
96

97
        return catalogue.GetAllExtractionInformation(ExtractionCategory.Any).Select(e => e.ColumnInfo)
×
98
            .Where(c => c != null).Distinct().ToArray();
×
99
    }
100

101
    protected ExecuteCommandViewFilterMatchData(IBasicActivateItems activator, ViewType viewType, FileInfo toFile) :
102
        base(activator, toFile)
×
103
    {
104
        _viewType = viewType;
×
105
    }
×
106

107
    public override string GetCommandName()
108
    {
109
        return _viewType switch
×
110
        {
×
111
            ViewType.TOP_100 => "View Extract",
×
112
            ViewType.Aggregate => "View Aggregate",
×
113
            _ => throw new ArgumentOutOfRangeException()
×
114
        };
×
115
    }
116

117
    protected override IViewSQLAndResultsCollection GetCollection()
118
    {
119
        _columnInfo ??= SelectOne(_candidates, _columnInfo != null ? _columnInfo.Name : "");
×
120

121
        if (_columnInfo == null)
×
122
            return null;
×
123

124
        ViewColumnExtractCollection collection = null;
×
125

126
        if (_filter != null)
×
127
            collection = new ViewColumnExtractCollection(_columnInfo, _viewType, _filter);
×
128
        if (_container != null)
×
129
            collection = new ViewColumnExtractCollection(_columnInfo, _viewType, _container);
×
130

131
        return collection == null
×
132
            ? throw new Exception("ViewFilterMatchData Command had no filter or container")
×
133
            : (IViewSQLAndResultsCollection)collection;
×
134
    }
135

136
    public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
137
        iconProvider.GetImage(RDMPConcept.ColumnInfo, OverlayKind.Filter);
×
138
}
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