-
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.
- Loading branch information
Showing
15 changed files
with
216 additions
and
47 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
31 changes: 31 additions & 0 deletions
31
Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCloneLoadMetadata.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,31 @@ | ||
using Rdmp.Core.Curation.Data.DataLoad; | ||
using Rdmp.Core.Curation.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Rdmp.Core.CommandExecution.AtomicCommands; | ||
|
||
public class ExecuteCommandCloneLoadMetadata : BasicCommandExecution | ||
{ | ||
private LoadMetadata _loadMetadata; | ||
private IBasicActivateItems _activator; | ||
public ExecuteCommandCloneLoadMetadata(IBasicActivateItems activator,[DemandsInitialization("The LoadMetadata to clone")] LoadMetadata loadMetadata) | ||
{ | ||
|
||
_loadMetadata = loadMetadata; | ||
_activator = activator; | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
var lmd = _loadMetadata.Clone(); | ||
lmd.Name = lmd.Name + " (Clone)"; | ||
lmd.SaveToDatabase(); | ||
_activator.Publish(lmd); | ||
|
||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandRestoreLoadMetadataVersion.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,48 @@ | ||
using Rdmp.Core.Curation.Data.DataLoad; | ||
using Rdmp.Core.Curation.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Org.BouncyCastle.Pqc.Crypto.Lms; | ||
|
||
namespace Rdmp.Core.CommandExecution.AtomicCommands; | ||
|
||
public class ExecuteCommandRestoreLoadMetadataVersion : BasicCommandExecution | ||
{ | ||
private LoadMetadata _loadMetadata; | ||
private IBasicActivateItems _activator; | ||
public ExecuteCommandRestoreLoadMetadataVersion(IBasicActivateItems activator, [DemandsInitialization("The LoadMetadata to version")] LoadMetadata loadMetadata) | ||
{ | ||
|
||
_loadMetadata = loadMetadata; | ||
_activator = activator; | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
if (!_activator.YesNo("Replace root Load Metadata with this configuration?","Resotre Load Metadata Version")) return; | ||
base.Execute(); | ||
if (_loadMetadata.RootLoadMetadata_ID is null) | ||
{ | ||
throw new Exception("Must Use a versioned LoadMetadata to create Version"); | ||
} | ||
LoadMetadata lmd = (LoadMetadata)_activator.RepositoryLocator.CatalogueRepository.GetObjectByID(typeof(LoadMetadata), (int)_loadMetadata.RootLoadMetadata_ID); | ||
if (lmd is null) | ||
{ | ||
throw new Exception("Could not find root load metadata"); | ||
|
||
} | ||
foreach (ProcessTask task in lmd.ProcessTasks) | ||
{ | ||
task.DeleteInDatabase(); | ||
} | ||
foreach(ProcessTask task in _loadMetadata.ProcessTasks) | ||
{ | ||
task.Clone(lmd); | ||
} | ||
lmd.SaveToDatabase(); | ||
_activator.Publish(lmd); | ||
} | ||
} |
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
49 changes: 49 additions & 0 deletions
49
Rdmp.Core/Providers/Nodes/LoadMetadataNodes/LoadMetadataVersionNodes.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,49 @@ | ||
// Copyright (c) The University of Dundee 2018-2019 | ||
// 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 System; | ||
using System.Collections.Generic; | ||
using Rdmp.Core.Curation.Data; | ||
using Rdmp.Core.Curation.Data.Cohort; | ||
using Rdmp.Core.Curation.Data.DataLoad; | ||
|
||
namespace Rdmp.Core.Providers.Nodes.LoadMetadataNodes; | ||
|
||
/// <summary> | ||
/// Collection of all the <see cref="Catalogue"/>s which are currently associated with a given <see cref="Curation.Data.DataLoad.LoadMetadata"/>. This governs | ||
/// which tables are created in RAW=>STAGING=>LIVE. | ||
/// </summary> | ||
public class LoadMetadataVersionNode : Node, IOrderable | ||
{ | ||
public LoadMetadata LoadMetadata { get; } | ||
|
||
public int Order | ||
{ | ||
get => 1; | ||
set { } | ||
} | ||
|
||
public List<LoadMetadata> LoadMetadataVersions { get; set; } | ||
|
||
public LoadMetadataVersionNode(LoadMetadata lmd) | ||
{ | ||
LoadMetadata = lmd; | ||
} | ||
|
||
public override string ToString() => "Versions"; | ||
|
||
protected bool Equals(LoadMetadataVersionNode other) => Equals(LoadMetadata, other.LoadMetadata); | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (obj is null) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != GetType()) return false; | ||
return Equals((LoadMetadataVersionNode)obj); | ||
} | ||
|
||
public override int GetHashCode() => HashCode.Combine(LoadMetadata); | ||
} |
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,18 @@ | ||
using Rdmp.Core.Curation.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Rdmp.Core.ReusableLibraryCode; | ||
|
||
internal interface IVersionable | ||
{ | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <returns></returns> | ||
DatabaseEntity SaveNewVersion(); | ||
} |