|
|
|
@ -11,10 +11,14 @@ using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Squidex.Domain.Apps.Core.Schemas; |
|
|
|
using Squidex.Domain.Apps.Entities.Apps; |
|
|
|
using Squidex.Domain.Apps.Entities.Apps.State; |
|
|
|
using Squidex.Domain.Apps.Entities.Assets; |
|
|
|
using Squidex.Domain.Apps.Entities.Assets.State; |
|
|
|
using Squidex.Domain.Apps.Entities.Contents.State; |
|
|
|
using Squidex.Domain.Apps.Entities.Rules; |
|
|
|
using Squidex.Domain.Apps.Entities.Rules.State; |
|
|
|
using Squidex.Domain.Apps.Entities.Schemas; |
|
|
|
using Squidex.Domain.Apps.Entities.Schemas.State; |
|
|
|
using Squidex.Domain.Apps.Events; |
|
|
|
using Squidex.Domain.Apps.Events.Assets; |
|
|
|
using Squidex.Domain.Apps.Events.Contents; |
|
|
|
@ -30,30 +34,44 @@ namespace Migrate_01 |
|
|
|
private readonly FieldRegistry fieldRegistry; |
|
|
|
private readonly IEventStore eventStore; |
|
|
|
private readonly IEventDataFormatter eventDataFormatter; |
|
|
|
private readonly ISnapshotStore<AppState, Guid> snapshotAppStore; |
|
|
|
private readonly ISnapshotStore<AssetState, Guid> snapshotAssetStore; |
|
|
|
private readonly ISnapshotStore<ContentState, Guid> snapshotContentStore; |
|
|
|
private readonly ISnapshotStore<RuleState, Guid> snapshotRuleStore; |
|
|
|
private readonly ISnapshotStore<SchemaState, Guid> snapshotSchemaStore; |
|
|
|
private readonly IStateFactory stateFactory; |
|
|
|
|
|
|
|
public Rebuilder( |
|
|
|
FieldRegistry fieldRegistry, |
|
|
|
IEventDataFormatter eventDataFormatter, |
|
|
|
IEventStore eventStore, |
|
|
|
ISnapshotStore<AppState, Guid> snapshotAppStore, |
|
|
|
ISnapshotStore<ContentState, Guid> snapshotContentStore, |
|
|
|
ISnapshotStore<AssetState, Guid> snapshotAssetStore, |
|
|
|
ISnapshotStore<RuleState, Guid> snapshotRuleStore, |
|
|
|
ISnapshotStore<SchemaState, Guid> snapshotSchemaStore, |
|
|
|
IStateFactory stateFactory) |
|
|
|
{ |
|
|
|
this.fieldRegistry = fieldRegistry; |
|
|
|
this.eventDataFormatter = eventDataFormatter; |
|
|
|
this.eventStore = eventStore; |
|
|
|
this.snapshotAppStore = snapshotAppStore; |
|
|
|
this.snapshotAssetStore = snapshotAssetStore; |
|
|
|
this.snapshotContentStore = snapshotContentStore; |
|
|
|
this.snapshotRuleStore = snapshotRuleStore; |
|
|
|
this.snapshotSchemaStore = snapshotSchemaStore; |
|
|
|
this.stateFactory = stateFactory; |
|
|
|
} |
|
|
|
|
|
|
|
public Task RebuildAssetsAsync() |
|
|
|
public async Task RebuildAssetsAsync() |
|
|
|
{ |
|
|
|
await snapshotAssetStore.ClearAsync(); |
|
|
|
|
|
|
|
const string filter = "^asset\\-"; |
|
|
|
|
|
|
|
var handledIds = new HashSet<Guid>(); |
|
|
|
|
|
|
|
return eventStore.GetEventsAsync(async storedEvent => |
|
|
|
await eventStore.GetEventsAsync(async storedEvent => |
|
|
|
{ |
|
|
|
var @event = ParseKnownEvent(storedEvent); |
|
|
|
|
|
|
|
@ -71,13 +89,17 @@ namespace Migrate_01 |
|
|
|
}, filter, cancellationToken: CancellationToken.None); |
|
|
|
} |
|
|
|
|
|
|
|
public Task RebuildConfigAsync() |
|
|
|
public async Task RebuildConfigAsync() |
|
|
|
{ |
|
|
|
await snapshotAppStore.ClearAsync(); |
|
|
|
await snapshotRuleStore.ClearAsync(); |
|
|
|
await snapshotSchemaStore.ClearAsync(); |
|
|
|
|
|
|
|
const string filter = "^((app\\-)|(schema\\-)|(rule\\-))"; |
|
|
|
|
|
|
|
var handledIds = new HashSet<Guid>(); |
|
|
|
|
|
|
|
return eventStore.GetEventsAsync(async storedEvent => |
|
|
|
await eventStore.GetEventsAsync(async storedEvent => |
|
|
|
{ |
|
|
|
var @event = ParseKnownEvent(storedEvent); |
|
|
|
|
|
|
|
@ -107,12 +129,12 @@ namespace Migrate_01 |
|
|
|
|
|
|
|
public async Task RebuildContentAsync() |
|
|
|
{ |
|
|
|
await snapshotContentStore.ClearAsync(); |
|
|
|
|
|
|
|
const string filter = "^((content\\-))"; |
|
|
|
|
|
|
|
var handledIds = new HashSet<Guid>(); |
|
|
|
|
|
|
|
await snapshotContentStore.ClearAsync(); |
|
|
|
|
|
|
|
await eventStore.GetEventsAsync(async storedEvent => |
|
|
|
{ |
|
|
|
var @event = ParseKnownEvent(storedEvent); |
|
|
|
|