Skip to content

Commit bc5aa6a

Browse files
committed
add force non project specific
1 parent 48cdec7 commit bc5aa6a

3 files changed

Lines changed: 103 additions & 1 deletion

File tree

‎Rdmp.Core/CommandExecution/AtomicCommandFactory.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ public IEnumerable<IAtomicCommand> CreateCommands(object o)
161161
SuggestedCategory = Extraction,
162162
OverrideCommandName = "Remove Project Specific Catalogue from a Project"
163163
};
164+
yield return new ExecuteCommandMakeProjectSpecificCatalogueNormalAgainForce(_activator, c, null)
165+
{
166+
Weight = -99.0009f,
167+
SuggestedCategory = Extraction,
168+
OverrideCommandName = "Remove Project Specific Catalogue from ALL Project"
169+
};
164170
}
165171
yield return new ExecuteCommandSetExtractionIdentifier(_activator, c, null, null)
166172
{

‎Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandMakeProjectSpecificCatalogueNormalAgain.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public override void Execute()
4646
var dataExportRepository = BasicActivator.RepositoryLocator.DataExportRepository;
4747

4848
base.Execute();
49-
_extractableDataSets = dataExportRepository.GetAllObjectsWithParent<ExtractableDataSet>(_catalogue).Where(eds => eds.Projects.Any() && eds.Projects.Select(p => ProjectSpecificCatalogueManager.CanMakeCatalogueNonProjectSpecific(dataExportRepository, _catalogue, eds, p)).Contains(true)).ToList();
49+
_extractableDataSets = dataExportRepository.GetAllObjectsWithParent<ExtractableDataSet>(_catalogue).Where(eds => eds.Projects.Any()).ToList();// && eds.Projects.Select(p => ProjectSpecificCatalogueManager.CanMakeCatalogueNonProjectSpecific(dataExportRepository, _catalogue, eds, p)).Contains(true)).ToList();
5050
if (!_extractableDataSets.Any())
5151
{
5252
SetImpossible("Cannot make Catalogue Non-Project specific");
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 Rdmp.Core.Curation.Data;
8+
using Rdmp.Core.DataExport.Data;
9+
using Rdmp.Core.Icons.IconProvision;
10+
using Rdmp.Core.Repositories;
11+
using Rdmp.Core.ReusableLibraryCode.Icons.IconProvision;
12+
using SixLabors.ImageSharp;
13+
using SixLabors.ImageSharp.PixelFormats;
14+
using System;
15+
using System.Collections.Generic;
16+
using System.Linq;
17+
18+
namespace Rdmp.Core.CommandExecution.AtomicCommands;
19+
20+
public class ExecuteCommandMakeProjectSpecificCatalogueNormalAgainForce : BasicCommandExecution, IAtomicCommand
21+
{
22+
private Catalogue _catalogue;
23+
//private List<ExtractableDataSet> _extractableDataSets;
24+
private ExtractableDataSet _extractableDataSet;
25+
//private Project _selectedProj;
26+
27+
public ExecuteCommandMakeProjectSpecificCatalogueNormalAgainForce(IBasicActivateItems activator, Catalogue catalogue, ExtractableDataSet eds) :
28+
base(activator)
29+
{
30+
_catalogue = catalogue;
31+
_extractableDataSet = eds;
32+
33+
34+
var dataExportRepository = BasicActivator.RepositoryLocator.DataExportRepository;
35+
if (dataExportRepository == null)
36+
{
37+
SetImpossible("Data Export functionality is not available");
38+
return;
39+
}
40+
}
41+
42+
public override string GetCommandHelp() =>
43+
"Take a dataset that was previously only usable with extractions of a specific project and make it free for use in any extraction project";
44+
45+
public override void Execute()
46+
{
47+
var dataExportRepository = BasicActivator.RepositoryLocator.DataExportRepository;
48+
49+
base.Execute();
50+
var eds = dataExportRepository.GetAllObjectsWithParent<ExtractableDataSet>(_catalogue);
51+
//var projects = eds.SelectMany(e => e.ExtractionConfigurations.Select(ec => ec.Project));
52+
foreach (var e in eds)
53+
{
54+
var projects = e.ExtractionConfigurations.Select(ec => ec.Project);
55+
foreach (var project in projects)
56+
{
57+
ProjectSpecificCatalogueManager.MakeCatalogueNonProjectSpecific(BasicActivator.RepositoryLocator.DataExportRepository, _catalogue, e, project as Project);
58+
}
59+
}
60+
Publish(_catalogue);
61+
//_extractableDataSets = dataExportRepository.GetAllObjectsWithParent<ExtractableDataSet>(_catalogue).Where(eds => eds.Projects.Any() && eds.Projects.Select(p => ProjectSpecificCatalogueManager.CanMakeCatalogueNonProjectSpecific(dataExportRepository, _catalogue, eds, p)).Contains(true)).ToList();
62+
//if (!_extractableDataSets.Any())
63+
//{
64+
// SetImpossible("Cannot make Catalogue Non-Project specific");
65+
// return;
66+
//}
67+
68+
69+
70+
//if (_extractableDataSet is null)
71+
//{
72+
73+
// var projectIds = _extractableDataSets.SelectMany(eds => eds.Projects.Where(p => ProjectSpecificCatalogueManager.CanMakeCatalogueNonProjectSpecific(dataExportRepository,_catalogue, eds,p))).Select(p => p.ID);
74+
// _selectedProj = SelectOne<Project>(BasicActivator.RepositoryLocator.DataExportRepository.GetAllObjectsInIDList<Project>(projectIds).ToList());
75+
// if (_selectedProj is null) return;
76+
// _extractableDataSet = _extractableDataSets.FirstOrDefault(eds => eds.Projects.Select(p => p.ID).Contains(_selectedProj.ID));
77+
//}
78+
//if (_extractableDataSet == null)
79+
//{
80+
// return;
81+
//}
82+
83+
//if (!_extractableDataSet.Projects.Any())
84+
//{
85+
// SetImpossible("Catalogue is not a project specific Catalogue");
86+
// return;
87+
//}
88+
89+
//ProjectSpecificCatalogueManager.MakeCatalogueNonProjectSpecific(BasicActivator.RepositoryLocator.DataExportRepository, _catalogue, _extractableDataSet,_selectedProj);
90+
91+
//Publish(_catalogue);
92+
}
93+
94+
public override Image<Rgba32> GetImage(IIconProvider iconProvider) =>
95+
Image.Load<Rgba32>(CatalogueIcons.MakeProjectSpecificCatalogueNormalAgain);
96+
}

0 commit comments

Comments
 (0)