Новый обработчек связей устаревших и обновлённых сущностей.

This commit is contained in:
2025-05-15 10:21:18 +04:00
parent afdc5d3f81
commit e46cd99f41
3 changed files with 62 additions and 1 deletions
@@ -17,6 +17,9 @@ public enum ProcessorGroupEnum
[Description("Архивы Нефиса: Подклассы")] [Description("Архивы Нефиса: Подклассы")]
AonprdSubclasses, AonprdSubclasses,
[Description("Архивы Нефиса: Завершение")]
AonprdFinalization,
[Description("Foundry EN: Подготовка")] [Description("Foundry EN: Подготовка")]
FoundryEnPreparation, FoundryEnPreparation,
@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json.Linq;
using Pf2eDataScrapper.App;
using Pf2eDataScrapper.Processors;
using Pf2eModel;
using Pf2eModel.Model.Base.Targets;
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Finalization;
[ProcessorCollection(
"aonprd:legacy-remaster",
InnerType = null,
CompendiumType = ProcessorCompendiumEnum.Aonprd,
Description = "Связь устаревших и обновлённых сущностей",
Group = ProcessorGroupEnum.AonprdFinalization,
Parallel = true
)]
internal class LegacyRemasterProcessors(ProcessorInput input) : AbstractInputProcessor(input)
{
private Pf2eDbContext Context { get; set; } = new();
public override void Process()
{
string aonprdId = Input.GetRequired<string>("id");
EntityExternal entity =
Context.EntityExternals.AsNoTracking().FirstOrDefault(x => x.ExternalId == aonprdId)
?? throw new SilentSkipItemException();
int entityId = entity.EntityId;
foreach (int remasterId in GetEntityIds("remaster_id"))
{
Context.LegacyRemasters.Add(new() { LegacyId = entityId, RemasterId = remasterId });
}
foreach (int legacyId in GetEntityIds("legacy_id"))
{
Context.LegacyRemasters.Add(new() { LegacyId = legacyId, RemasterId = entityId });
}
}
protected List<int> GetEntityIds(string path)
{
List<string> aonprdIds = (Input.GetOptional<JArray>("path") ?? [])
.Select(token => token.ToString())
.ToList();
return Context
.EntityExternals.AsNoTracking()
.Where(x => aonprdIds.Contains(x.ExternalId))
.Select(x => x.EntityId)
.ToList();
}
public override void Save()
{
Context.SaveChanges();
}
}
@@ -16,7 +16,7 @@ namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Types;
Description = "Признаки", Description = "Признаки",
Group = ProcessorGroupEnum.AonprdEntities Group = ProcessorGroupEnum.AonprdEntities
)] )]
[ProcessorDependencies(["aonprd:legacy"])] [ProcessorDependencies(["aonprd:external", "aonprd:source"])]
internal class TraitProcessor( internal class TraitProcessor(
ProcessorInput input, ProcessorInput input,
StringHelper stringHelper, StringHelper stringHelper,