• 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

0.0
/Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandPutIntoFolder.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.CommandExecution.Combining;
10
using Rdmp.Core.Curation.Data;
11
using Rdmp.Core.Icons.IconProvision;
12
using Rdmp.Core.Repositories.Construction;
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 ExecuteCommandPutIntoFolder : BasicCommandExecution
20
{
21
    private readonly IHasFolder[] _toMove;
22
    private readonly string _folder;
23

24
    public ExecuteCommandPutIntoFolder(IBasicActivateItems activator, IHasFolderCombineable cmd, string targetModel)
25
        : this(activator, new[] { cmd.Folderable }, targetModel)
×
26
    {
27
    }
×
28

29
    public ExecuteCommandPutIntoFolder(IBasicActivateItems activator, ManyCataloguesCombineable cmd, string targetModel)
30
        : this(activator, cmd.Catalogues, targetModel)
×
31
    {
32
    }
×
33

34
    [UseWithObjectConstructor]
35
    public ExecuteCommandPutIntoFolder(IBasicActivateItems activator, IHasFolder[] toMove, string folder) :
36
        base(activator)
×
37
    {
38
        _folder = folder;
×
39
        _toMove = toMove;
×
40
    }
×
41

42
    public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
43
        OverrideIcon ?? Image.Load<Rgba32>(CatalogueIcons.CatalogueFolder);
×
44

45
    public override void Execute()
46
    {
47
        base.Execute();
×
48

49
        var f = _folder;
×
50
        if (f == null)
×
51
        {
52
            if (BasicActivator.IsInteractive)
×
53
            {
54
                // if there's a single current value for the folder
55
                // of these objects (i.e. they are only operating on one item
56
                // or on several items in the same folder).  Then make the
57
                // popup text box show the old value.  Otherwise show the root \
58
                var current = _toMove.Select(m => m.Folder).Distinct().ToArray();
×
59
                var oldValue = current.Length == 1 ? current[0] : "\\";
×
60

61
                if (!BasicActivator.TypeText(new DialogArgs
×
62
                {
×
63
                    WindowTitle = "Folder",
×
64
                    TaskDescription =
×
65
                            "Enter a new virtual folder for the object.  Folder names should be lower case and start with a backslash ('\\')",
×
66
                    EntryLabel = "New Folder"
×
67
                }, 500, oldValue, out f, false))
×
68
                    return;
×
69
            }
70
            else
71
            {
72
                throw new Exception("No new folder value was passed and User Interface is not interactive");
×
73
            }
74
        }
75

76
        // user entered a blank string, treat that as cancellation
77
        if (string.IsNullOrWhiteSpace(f))
×
78
            return;
×
79

80
        foreach (var c in _toMove)
×
81
        {
82
            c.Folder = f;
×
83
            c.SaveToDatabase();
×
84
        }
85

86
        //Folder has changed so publish the change (but only change the last Catalogue so we don't end up subbing a million global refresh changes)
87
        Publish(_toMove.Last());
×
88
    }
×
89
}
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