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

HicServices / RDMP / 16004090609

01 Jul 2025 03:47PM UTC coverage: 57.442% (+0.1%) from 57.314%
16004090609

Pull #2205

github

JFriel
add db change
Pull Request #2205: Multi-Project Catalogues

11417 of 21406 branches covered (53.34%)

Branch coverage included in aggregate %.

71 of 100 new or added lines in 8 files covered. (71.0%)

27 existing lines in 1 file now uncovered.

32373 of 54827 relevant lines covered (59.05%)

8775.92 hits per line

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

52.38
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandMakeProjectSpecificCatalogueNormalAgain.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 Rdmp.Core.Curation.Data;
10
using Rdmp.Core.DataExport.Data;
11
using Rdmp.Core.Icons.IconProvision;
12
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
13
using SixLabors.ImageSharp;
14
using SixLabors.ImageSharp.PixelFormats;
15

16
namespace Rdmp.Core.CommandExecution.AtomicCommands;
17

18
public class ExecuteCommandMakeProjectSpecificCatalogueNormalAgain : BasicCommandExecution, IAtomicCommand
19
{
20
    private Catalogue _catalogue;
21
    private List<ExtractableDataSet> _extractableDataSets;
22
    private ExtractableDataSet _extractableDataSet;
23

24
    public ExecuteCommandMakeProjectSpecificCatalogueNormalAgain(IBasicActivateItems activator, Catalogue catalogue, ExtractableDataSet eds) :
25
        base(activator)
7✔
26
    {
27
        _catalogue = catalogue;
7✔
28
        _extractableDataSet = eds;
7✔
29

30

31
        var dataExportRepository = BasicActivator.RepositoryLocator.DataExportRepository;
7✔
32
        if (dataExportRepository == null)
7!
33
        {
34
            SetImpossible("Data Export functionality is not available");
×
35
            return;
×
36
        }
37

38
        _extractableDataSets = dataExportRepository.GetAllObjectsWithParent<ExtractableDataSet>(catalogue).Where(eds => eds.Project_ID != null && ProjectSpecificCatalogueManager.CanMakeCatalogueNonProjectSpecific(dataExportRepository, catalogue, eds)).ToList();
19✔
39
        if (!_extractableDataSets.Any())
7!
40
        {
NEW
41
            SetImpossible("Cannot make Catalogue Non-Project specific");
×
42
            return;
×
43
        }
44
        
45

46
    }
7✔
47

48
    public override string GetCommandHelp() =>
49
        "Take a dataset that was previously only usable with extractions of a specific project and make it free for use in any extraction project";
×
50

51
    public override void Execute()
52
    {
53
        base.Execute();
6✔
54
        if (_extractableDataSet is null)
6!
55
        {
NEW
56
            var projectIds = _extractableDataSets.Where(eds => eds.Project_ID != null).Select(eds => (int)eds.Project_ID);
×
NEW
57
            var selectedProj = SelectOne<Project>(BasicActivator.RepositoryLocator.DataExportRepository.GetAllObjectsInIDList<Project>(projectIds).ToList());
×
NEW
58
            if (selectedProj is null) return;
×
NEW
59
            _extractableDataSet = _extractableDataSets.FirstOrDefault(eds => eds.Project_ID == selectedProj.ID);
×
60
        }
61
        if (_extractableDataSet == null)
6!
62
        {
NEW
63
            return;
×
64
        }
65

66
        if (_extractableDataSet.Project_ID == null)
6!
67
        {
NEW
68
            SetImpossible("Catalogue is not a project specific Catalogue");
×
NEW
69
            return;
×
70
        }
71

72
        ProjectSpecificCatalogueManager.MakeCatalogueNonProjectSpecific(BasicActivator.RepositoryLocator.DataExportRepository, _catalogue, _extractableDataSet);
6✔
73

74
        Publish(_catalogue);
6✔
75
    }
6✔
76

77
    public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
78
        Image.Load<Rgba32>(CatalogueIcons.MakeProjectSpecificCatalogueNormalAgain);
×
79
}
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