Skip to content

Commit 89036d0

Browse files
committed
add basic versioning
1 parent eb42881 commit 89036d0

File tree

9 files changed

+64
-16
lines changed

9 files changed

+64
-16
lines changed

Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewClassBasedProcessTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public override void Execute()
7272
else
7373
return;
7474
}
75-
75+
_loadMetadata.Clone();
7676
var newTask = new ProcessTask(BasicActivator.RepositoryLocator.CatalogueRepository, _loadMetadata, _loadStage)
7777
{
7878
Path = _type.FullName,

Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandCreateNewFileBasedProcessTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public override void Execute()
9696
throw new ArgumentOutOfRangeException($"Unexpected _taskType:{_taskType}");
9797
}
9898
}
99-
99+
_loadMetadata.Clone();
100100
var task = new ProcessTask((ICatalogueRepository)_loadMetadata.Repository, _loadMetadata, _loadStage)
101101
{
102102
ProcessTaskType = _taskType,

Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandDisableOrEnable.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
using Rdmp.Core.Curation.Data;
99
using Rdmp.Core.Curation.Data.Aggregation;
1010
using Rdmp.Core.Curation.Data.Cohort;
11+
using Rdmp.Core.Curation.Data.DataLoad;
1112
using Rdmp.Core.MapsDirectlyToDatabaseTable;
13+
using Rdmp.Core.ReusableLibraryCode;
1214

1315
namespace Rdmp.Core.CommandExecution.AtomicCommands;
1416

@@ -72,8 +74,18 @@ public override void Execute()
7274

7375
foreach (var d in _targets)
7476
{
75-
d.IsDisabled = !d.IsDisabled;
76-
d.SaveToDatabase();
77+
var x = d.GetType();
78+
if (d.GetType() == typeof(ProcessTask))
79+
{
80+
var newVersion = (IDisableable)((IVersionable)d).SaveNewVersion();
81+
newVersion.IsDisabled = true;
82+
newVersion.SaveToDatabase();
83+
}
84+
else
85+
{
86+
d.IsDisabled = !d.IsDisabled;
87+
d.SaveToDatabase();
88+
}
7789
}
7890

7991
var toRefresh = _targets.FirstOrDefault();

Rdmp.Core/CommandExecution/AtomicCommands/ExecuteCommandToggleAllowReservedPrefixForLoadMetadata.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public ExecuteCommandToggleAllowReservedPrefixForLoadMetadata([DemandsInitializa
2424
public override void Execute()
2525
{
2626
base.Execute();
27+
_loadMetadata.Clone();
2728
_loadMetadata.AllowReservedPrefix = !_loadMetadata.AllowReservedPrefix;
2829
_loadMetadata.SaveToDatabase();
2930
}

Rdmp.Core/Curation/Data/DataLoad/IProcessTask.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,4 @@ public interface IProcessTask : IRevertable, IArgumentHost, IOrderable, IDisable
4848
/// </summary>
4949
#nullable enable
5050
string? SerialisableConfiguration { get; }
51-
52-
53-
int LoadMetadataVersion { get; }
5451
}

Rdmp.Core/Curation/Data/DataLoad/LoadMetadata.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public enum CacheArchiveType
4545

4646
/// <inheritdoc cref="ILoadMetadata"/>
4747
public class LoadMetadata : DatabaseEntity, ILoadMetadata, IHasDependencies, IHasQuerySyntaxHelper,
48-
ILoggedActivityRootObject, IHasFolder
48+
ILoggedActivityRootObject, IHasFolder, IVersionable
4949
{
5050
#region Database Properties
5151

@@ -273,7 +273,7 @@ internal LoadMetadata(ICatalogueRepository repository, DbDataReader r)
273273

274274
public LoadMetadata Clone()
275275
{
276-
return new LoadMetadata()
276+
var lmd = new LoadMetadata(CatalogueRepository, this.Name)
277277
{
278278
LocationOfForLoadingDirectory = LocationOfForLoadingDirectory,
279279
LocationOfForArchivingDirectory = LocationOfForArchivingDirectory,
@@ -283,13 +283,22 @@ public LoadMetadata Clone()
283283
Name = Name,
284284
Description = Description,
285285
CacheArchiveType = CacheArchiveType,
286-
AllowReservedPrefix = AllowReservedPrefix,
286+
AllowReservedPrefix = false,
287287
LastLoadTime = LastLoadTime,
288288
OverrideRAWServer_ID = OverrideRAWServer_ID,
289289
IgnoreTrigger = IgnoreTrigger,
290290
Folder = Folder,
291-
RootLoadMetadata_ID = RootLoadMetadata_ID != null?RootLoadMetadata_ID: this.ID
291+
RootLoadMetadata_ID = this.ID
292292
};
293+
lmd.SaveToDatabase();
294+
//link to catalogue
295+
//process task
296+
var pts = CatalogueRepository.GetAllObjectsWhere<ProcessTask>("LoadMetadata_ID", this.ID);
297+
foreach(ProcessTask pt in pts)
298+
{
299+
pt.Clone(lmd);
300+
}
301+
return lmd;
293302
}
294303

295304
internal LoadMetadata(ShareManager shareManager, ShareDefinition shareDefinition) : base()
@@ -494,4 +503,14 @@ public static bool UsesPersistentRaw(ILoadMetadata loadMetadata)
494503
return loadMetadata.CatalogueRepository.GetExtendedProperties(ExtendedProperty.PersistentRaw,
495504
loadMetadata).Any(p => p.Value == "true");
496505
}
506+
507+
508+
/// <inheritdoc/>
509+
public DatabaseEntity SaveNewVersion()
510+
{
511+
var lmd = this.Clone();
512+
lmd.RootLoadMetadata_ID = this.RootLoadMetadata_ID != null ? this.RootLoadMetadata_ID : this.ID;
513+
lmd.SaveToDatabase();
514+
return lmd;
515+
}
497516
}

Rdmp.Core/Curation/Data/DataLoad/ProcessTask.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Rdmp.Core.MapsDirectlyToDatabaseTable;
1717
using Rdmp.Core.MapsDirectlyToDatabaseTable.Attributes;
1818
using Rdmp.Core.Repositories;
19+
using Rdmp.Core.ReusableLibraryCode;
1920
using Rdmp.Core.ReusableLibraryCode.Annotations;
2021
using Rdmp.Core.ReusableLibraryCode.Checks;
2122

@@ -47,7 +48,6 @@ public class ProcessTask : DatabaseEntity, IProcessTask, IOrderable, INamed, ICh
4748
#nullable enable
4849
private string? _SerialisableConfiguration;
4950
#nullable disable
50-
private int _loadMetadataVersion;
5151

5252
/// <summary>
5353
/// The load the process task exists as part of
@@ -122,7 +122,6 @@ public string? SerialisableConfiguration
122122
}
123123

124124

125-
public int LoadMetadataVersion { get => _loadMetadataVersion; set => SetField(ref _loadMetadataVersion, value); }
126125
#nullable disable
127126

128127
#endregion
@@ -207,7 +206,6 @@ internal ProcessTask(ICatalogueRepository repository, DbDataReader r)
207206
Path = r["Path"] as string;
208207
Name = r["Name"] as string;
209208
Order = int.Parse(r["Order"].ToString());
210-
LoadMetadataVersion = int.Parse(r["LoadMetadataVersion"].ToString());
211209
if (Enum.TryParse(r["ProcessTaskType"] as string, out ProcessTaskType processTaskType))
212210
ProcessTaskType = processTaskType;
213211
else
@@ -450,4 +448,24 @@ public void SetArgumentValue(string parameterName, object o)
450448
matchingArgument.SetValue(o);
451449
matchingArgument.SaveToDatabase();
452450
}
451+
452+
453+
public ProcessTask Clone(LoadMetadata lmd)
454+
{
455+
var pt = new ProcessTask(this.CatalogueRepository, lmd, this.LoadStage) {
456+
ProcessTaskType = this.ProcessTaskType,
457+
Order = this.Order,
458+
IsDisabled = this.IsDisabled,
459+
SerialisableConfiguration = this.SerialisableConfiguration,
460+
Path = this.Path,
461+
Name= this.Name,
462+
};
463+
pt.LoadMetadata_ID = lmd.ID;
464+
pt.SaveToDatabase();
465+
foreach(var pta in ProcessTaskArguments)
466+
{
467+
pta.ShallowClone(pt);
468+
}
469+
return pt;
470+
}
453471
}

Rdmp.Core/Databases/CatalogueDatabase/runAfterCreateDatabase/CreateCatalogue.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ CREATE TABLE [dbo].[ProcessTask](
774774
[SoftwareVersion] [nvarchar](50) NOT NULL,
775775
[IsDisabled] [bit] NOT NULL,
776776
[SerialisableConfiguration] [varchar](max),
777+
[LoadMetadataVersion] [int],
777778
CONSTRAINT [PK_ProcessTask] PRIMARY KEY CLUSTERED
778779
(
779780
[ID] ASC

Rdmp.Core/Providers/CatalogueChildProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,8 @@ private void AddChildren(AllProcessTasksUsedByLoadMetadataNode allProcessTasksUs
998998
private void AddChildren(LoadStageNode loadStageNode, DescendancyList descendancy)
999999
{
10001000
var tasks = AllProcessTasks.Where(
1001-
p => p.LoadMetadata_ID == loadStageNode.LoadMetadata.ID && p.LoadStage == loadStageNode.LoadStage)
1002-
.OrderBy(o => o.Order).ToArray();
1001+
p => p.LoadMetadata_ID == loadStageNode.LoadMetadata.ID && p.LoadStage == loadStageNode.LoadStage)
1002+
.OrderBy(o => o.Order).ToArray();
10031003

10041004
foreach (var processTask in tasks)
10051005
AddChildren(processTask, descendancy.Add(processTask));

0 commit comments

Comments
 (0)