-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/rdmp 253 filter ordering (#2007)
* add start * partial * tidy up code * filter updates * update db migrations * update correct db * update changelog * add base creation sql * fix create * tidy up
- Loading branch information
Showing
14 changed files
with
131 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Rdmp.Core/Databases/CatalogueDatabase/up/087_AddAggregateFilterOrdering.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
----Version: 8.4.0 | ||
----Description: Add Order to Aggregate Filters | ||
|
||
if not exists (select 1 from sys.columns where name = 'Order' and OBJECT_NAME(object_id) = 'AggregateFilter') | ||
BEGIN | ||
ALTER TABLE [dbo].[AggregateFilter] | ||
ADD [Order] [int] NOT NULL DEFAULT 0 WITH VALUES | ||
END | ||
if not exists (select 1 from sys.columns where name = 'Order' and OBJECT_NAME(object_id) = 'ExtractionFilter') | ||
BEGIN | ||
ALTER TABLE [dbo].[ExtractionFilter] | ||
ADD [Order] [int] NOT NULL DEFAULT 0 WITH VALUES | ||
END |
Binary file modified
BIN
+70 Bytes
(100%)
Rdmp.Core/Databases/DataExportDatabase/runAfterCreateDatabase/CreateDataExportManager.sql
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
Rdmp.Core/Databases/DataExportDatabase/up/026_AddFilterOrder.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
----Version: 8.4.0 | ||
----Description: Add Order to Aggregate Filters | ||
|
||
if not exists (select 1 from sys.columns where name = 'Order' and OBJECT_NAME(object_id) = 'DeployedExtractionFilter') | ||
BEGIN | ||
ALTER TABLE [dbo].[DeployedExtractionFilter] | ||
ADD [Order] [int] NOT NULL DEFAULT 0 WITH VALUES | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Rdmp.UI/CommandExecution/AtomicCommands/ExecuteCommandReorderFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) The University of Dundee 2024-2024 | ||
// This file is part of the Research Data Management Platform (RDMP). | ||
// 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. | ||
// 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. | ||
// You should have received a copy of the GNU General Public License along with RDMP. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
using Rdmp.Core.Curation.Data; | ||
using Rdmp.Core.MapsDirectlyToDatabaseTable; | ||
using Rdmp.UI.ItemActivation; | ||
using System; | ||
using System.Linq; | ||
|
||
namespace Rdmp.UI.CommandExecution.AtomicCommands; | ||
|
||
public class ExecuteCommandReorderFilter : BasicUICommandExecution | ||
{ | ||
private ConcreteFilter _source; | ||
Check notice Code scanning / CodeQL Missed 'readonly' opportunity Note
Field '_source' can be 'readonly'.
|
||
private ConcreteFilter _target; | ||
Check notice Code scanning / CodeQL Missed 'readonly' opportunity Note
Field '_target' can be 'readonly'.
|
||
private InsertOption _insertOption; | ||
Check notice Code scanning / CodeQL Missed 'readonly' opportunity Note
Field '_insertOption' can be 'readonly'.
|
||
|
||
public ExecuteCommandReorderFilter(IActivateItems activator, ConcreteFilter source, ConcreteFilter destination, InsertOption insertOption) : base(activator) | ||
{ | ||
_source = source; | ||
_target = destination; | ||
_insertOption = insertOption; | ||
if (_source.FilterContainer_ID is null || _target.FilterContainer_ID is null) | ||
{ | ||
SetImpossible("Both filters must exist within some container in order to be orderable"); | ||
} | ||
if (_source.FilterContainer_ID != _target.FilterContainer_ID) | ||
{ | ||
SetImpossible("Cannot reorder filters as they do not share a parent"); | ||
} | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
var order = _target.Order; | ||
|
||
var filters = _target.FilterContainer.GetFilters().Where(f => f is ConcreteFilter).Select(f => (ConcreteFilter)f).ToArray(); | ||
Array.Sort( | ||
filters, | ||
delegate (ConcreteFilter a, ConcreteFilter b) { return a.Order.CompareTo(b.Order); } | ||
); | ||
if (!filters.All(c => c.Order != order)) | ||
{ | ||
foreach (var orderable in filters) | ||
{ | ||
if (orderable.Order < order) | ||
orderable.Order--; | ||
else if (orderable.Order > order) | ||
orderable.Order++; | ||
else //collision on order | ||
orderable.Order += _insertOption == InsertOption.InsertAbove ? 1 : -1; | ||
((ISaveable)orderable).SaveToDatabase(); | ||
} | ||
} | ||
_source.Order = order; | ||
_source.SaveToDatabase(); | ||
Publish(_target.FilterContainer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters