mirror of https://github.com/Squidex/squidex.git
49 changed files with 629 additions and 323 deletions
@ -0,0 +1,31 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using NodaTime; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Squidex.Domain.Apps.Core.HandleRules.EnrichedEvents |
|||
{ |
|||
public abstract class EnrichedEntityEvent : EnrichedEvent |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public Instant Created { get; set; } |
|||
|
|||
public Instant LastModified { get; set; } |
|||
|
|||
public RefToken CreatedBy { get; set; } |
|||
|
|||
public RefToken LastModifiedBy { get; set; } |
|||
|
|||
public override void CalculatePartition() |
|||
{ |
|||
Partition = Id.GetHashCode(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,67 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Squidex.Domain.Apps.Core.HandleRules.EnrichedEvents; |
|||
using Squidex.Domain.Apps.Core.Rules; |
|||
using Squidex.Domain.Apps.Core.Rules.Triggers; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Migrate_01.OldTriggers |
|||
{ |
|||
[TypeName(nameof(AssetChangedTrigger))] |
|||
public sealed class AssetChangedTrigger : RuleTrigger, IMigrated<RuleTrigger> |
|||
{ |
|||
public bool SendCreate { get; set; } |
|||
|
|||
public bool SendUpdate { get; set; } |
|||
|
|||
public bool SendRename { get; set; } |
|||
|
|||
public bool SendDelete { get; set; } |
|||
|
|||
public override T Accept<T>(IRuleTriggerVisitor<T> visitor) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
|
|||
public RuleTrigger Migrate() |
|||
{ |
|||
var conditions = new List<string>(); |
|||
|
|||
if (SendCreate) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedAssetEventType.Created}'"); |
|||
} |
|||
|
|||
if (SendUpdate) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedAssetEventType.Updated}'"); |
|||
} |
|||
|
|||
if (SendRename) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedAssetEventType.Renamed}'"); |
|||
} |
|||
|
|||
if (SendDelete) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedAssetEventType.Deleted}'"); |
|||
} |
|||
|
|||
var condition = "false"; |
|||
|
|||
if (conditions.Count > 0) |
|||
{ |
|||
condition = string.Join(" || ", conditions); |
|||
} |
|||
|
|||
return new AssetChangedTriggerV2 { Condition = condition }; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.ObjectModel; |
|||
using Squidex.Domain.Apps.Core.Rules; |
|||
using Squidex.Infrastructure; |
|||
|
|||
namespace Migrate_01.OldTriggers |
|||
{ |
|||
[TypeName(nameof(ContentChangedTrigger))] |
|||
public sealed class ContentChangedTrigger : RuleTrigger, IMigrated<RuleTrigger> |
|||
{ |
|||
public ReadOnlyCollection<ContentChangedTriggerSchema> Schemas { get; set; } |
|||
|
|||
public bool HandleAll { get; set; } |
|||
|
|||
public override T Accept<T>(IRuleTriggerVisitor<T> visitor) |
|||
{ |
|||
throw new NotSupportedException(); |
|||
} |
|||
|
|||
public override void Freeze() |
|||
{ |
|||
base.Freeze(); |
|||
|
|||
if (Schemas != null) |
|||
{ |
|||
foreach (var schema in Schemas) |
|||
{ |
|||
schema.Freeze(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public RuleTrigger Migrate() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Squidex.Domain.Apps.Core; |
|||
using Squidex.Domain.Apps.Core.HandleRules.EnrichedEvents; |
|||
using Squidex.Domain.Apps.Core.Rules.Triggers; |
|||
|
|||
namespace Migrate_01.OldTriggers |
|||
{ |
|||
public sealed class ContentChangedTriggerSchema : Freezable |
|||
{ |
|||
public Guid SchemaId { get; set; } |
|||
|
|||
public bool SendCreate { get; set; } |
|||
|
|||
public bool SendUpdate { get; set; } |
|||
|
|||
public bool SendDelete { get; set; } |
|||
|
|||
public bool SendPublish { get; set; } |
|||
|
|||
public bool SendUnpublish { get; set; } |
|||
|
|||
public bool SendArchived { get; set; } |
|||
|
|||
public bool SendRestore { get; set; } |
|||
|
|||
public ContentChangedTriggerSchemaV2 Migrate() |
|||
{ |
|||
var conditions = new List<string>(); |
|||
|
|||
if (SendCreate) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Created}'"); |
|||
} |
|||
|
|||
if (SendUpdate) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Updated}'"); |
|||
} |
|||
|
|||
if (SendPublish) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Published}'"); |
|||
} |
|||
|
|||
if (SendUnpublish) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Unpublished}'"); |
|||
} |
|||
|
|||
if (SendArchived) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Archived}'"); |
|||
} |
|||
|
|||
if (SendRestore) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedContentEventType.Restored}'"); |
|||
} |
|||
|
|||
if (SendDelete) |
|||
{ |
|||
conditions.Add($"event.type == '{EnrichedAssetEventType.Deleted}'"); |
|||
} |
|||
|
|||
var condition = "false"; |
|||
|
|||
if (conditions.Count > 0) |
|||
{ |
|||
condition = string.Join(" || ", conditions); |
|||
} |
|||
|
|||
return new ContentChangedTriggerSchemaV2 { SchemaId = SchemaId, Condition = condition }; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue