Глобальное обновление #1

Merged
kozhilya merged 33 commits from dev into master 2025-06-01 22:28:15 +04:00
13 changed files with 77 additions and 152 deletions
Showing only changes of commit 4d01b100d1 - Show all commits
+6 -6
View File
@@ -7,7 +7,8 @@ using Pf2eDataScrapper.Helpers;
using Pf2eDataScrapper.Processors; using Pf2eDataScrapper.Processors;
using Pf2eDataScrapper.WPF; using Pf2eDataScrapper.WPF;
using Pf2eDataScrapper.WPF.EntityViewer; using Pf2eDataScrapper.WPF.EntityViewer;
using Pf2eDataScrapper.WPF.Views; using Pf2eDataScrapper.WPF.ProgressForm;
using Pf2eDataScrapper.WPF.StartForm;
using Pf2eModel; using Pf2eModel;
using Slugify; using Slugify;
@@ -50,7 +51,7 @@ internal sealed class ImportApplication : Application
#endregion #endregion
#region "Формы" #region "Жизненный цикл"
private StartForm? _startFormWpf; private StartForm? _startFormWpf;
@@ -58,10 +59,6 @@ internal sealed class ImportApplication : Application
private EntityForm? _entityForm; private EntityForm? _entityForm;
#endregion
#region "Жизненный цикл"
private Window? CurrentWpfForm { get; set; } private Window? CurrentWpfForm { get; set; }
public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage); public delegate void ApplicationStateChangeDelegate(object sender, ApplicationStage nextStage);
@@ -133,6 +130,9 @@ internal sealed class ImportApplication : Application
break; break;
case ApplicationStage.ImportProcess: case ApplicationStage.ImportProcess:
_progressFormWpf!.Hide();
_progressFormWpf!.Close();
_progressFormWpf = null;
break; break;
case ApplicationStage.Viewer: case ApplicationStage.Viewer:
@@ -59,14 +59,14 @@ internal partial class StringHelper
} }
/// <summary> /// <summary>
/// Извлечение информации о названии источника. /// Извлечение суффикса из описания источника.
/// </summary> /// </summary>
/// <param name="input">Исходная строка.</param> /// <param name="input">Исходная строка.</param>
/// <returns>Название источника.</returns> /// <returns>Суффикс.</returns>
public string ResolveSource(string input) public string ResolveSourceSuffix(string input)
{ {
Match match = SourceSuffixRegex().Match(input); Match match = SourceSuffixRegex().Match(input);
return match.Captures.Count > 0 ? match.Captures[0].Value : ""; return match.Captures.Count > 0 ? match.Groups[1].Value : "";
} }
/// <summary> /// <summary>
@@ -173,7 +173,9 @@ internal abstract class AbstractEntityProcessor(
{ {
Entity = Entity, Entity = Entity,
SourceId = Globals.SourceIds[sourceName], SourceId = Globals.SourceIds[sourceName],
Suffix = StringHelper.ResolveSource(Input.GetRequired<string>("source_markdown")), Suffix = StringHelper.ResolveSourceSuffix(
Input.GetRequired<string>("source_markdown")
),
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null, IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null,
}; };
@@ -195,6 +197,7 @@ internal abstract class AbstractEntityProcessor(
Md5 = Input.Md5(), Md5 = Input.Md5(),
}; };
Entity.Externals.Add(external);
Context.EntityExternals.Add(external); Context.EntityExternals.Add(external);
} }
@@ -33,16 +33,17 @@ internal class LegacyRemasterProcessors(ProcessorInput input) : AbstractInputPro
{ {
Context.LegacyRemasters.Add(new() { LegacyId = entityId, RemasterId = remasterId }); Context.LegacyRemasters.Add(new() { LegacyId = entityId, RemasterId = remasterId });
} }
/*
foreach (int legacyId in GetEntityIds("legacy_id")) foreach (int legacyId in GetEntityIds("legacy_id"))
{ {
Context.LegacyRemasters.Add(new() { LegacyId = legacyId, RemasterId = entityId }); Context.LegacyRemasters.Add(new() { LegacyId = legacyId, RemasterId = entityId });
} }
*/
} }
protected List<int> GetEntityIds(string path) protected List<int> GetEntityIds(string path)
{ {
List<string> aonprdIds = (Input.GetOptional<JArray>("path") ?? []) List<string> aonprdIds = (Input.GetOptional<JArray>(path) ?? [])
.Select(token => token.ToString()) .Select(token => token.ToString())
.ToList(); .ToList();
@@ -109,6 +109,10 @@ internal class SpellProcessor(
{ {
A(new() { Spell = Object, Type = SpellAreaType.Square }); A(new() { Spell = Object, Type = SpellAreaType.Square });
} }
if (areaDetails.Contains("fungi"))
{
areaDetails = [areaDetails[0] + " or " + areaDetails[1]];
}
if (areaTypes.Count != areaDetails.Count) if (areaTypes.Count != areaDetails.Count)
{ {
@@ -13,7 +13,7 @@ using Pf2eModel.Model.Enum;
namespace Pf2eModel.Migrations namespace Pf2eModel.Migrations
{ {
[DbContext(typeof(Pf2eDbContext))] [DbContext(typeof(Pf2eDbContext))]
[Migration("20250516162158_1")] [Migration("20250521102908_1")]
partial class _1 partial class _1
{ {
/// <inheritdoc /> /// <inheritdoc />
@@ -288,36 +288,11 @@ namespace Pf2eModel.Migrations
.HasColumnOrder(2) .HasColumnOrder(2)
.HasComment("Идентификатор цели"); .HasComment("Идентификатор цели");
b.Property<int>("LegacyEntitiesId")
.HasColumnType("integer")
.HasColumnName("legacy_entities_id");
b.Property<int>("LegacyEntityId")
.HasColumnType("integer")
.HasColumnName("legacy_entity_id");
b.Property<int>("RemasterEntitiesId")
.HasColumnType("integer")
.HasColumnName("remaster_entities_id");
b.Property<int>("RemasterEntityId")
.HasColumnType("integer")
.HasColumnName("remaster_entity_id");
b.HasKey("LegacyId", "RemasterId") b.HasKey("LegacyId", "RemasterId")
.HasName("pk_legacy_remasters"); .HasName("pk_legacy_remasters");
b.HasIndex("LegacyEntitiesId") b.HasIndex("RemasterId")
.HasDatabaseName("ix_legacy_remasters_legacy_entities_id"); .HasDatabaseName("ix_legacy_remasters_remaster_id");
b.HasIndex("LegacyEntityId")
.HasDatabaseName("ix_legacy_remasters_legacy_entity_id");
b.HasIndex("RemasterEntitiesId")
.HasDatabaseName("ix_legacy_remasters_remaster_entities_id");
b.HasIndex("RemasterEntityId")
.HasDatabaseName("ix_legacy_remasters_remaster_entity_id");
b.ToTable("legacy_remasters", (string)null); b.ToTable("legacy_remasters", (string)null);
}); });
@@ -1973,33 +1948,19 @@ namespace Pf2eModel.Migrations
modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b => modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b =>
{ {
b.HasOne("Pf2eModel.Model.Base.Entity", null)
.WithMany()
.HasForeignKey("LegacyEntitiesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_legacy_entities_id");
b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity") b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity")
.WithMany() .WithMany("LegacyTransferEntities")
.HasForeignKey("LegacyEntityId") .HasForeignKey("LegacyId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired() .IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_legacy_entity_id"); .HasConstraintName("fk_legacy_remasters_entities_legacy_id");
b.HasOne("Pf2eModel.Model.Base.Entity", null)
.WithMany()
.HasForeignKey("RemasterEntitiesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_remaster_entities_id");
b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity") b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity")
.WithMany() .WithMany("RemasterTransferEntities")
.HasForeignKey("RemasterEntityId") .HasForeignKey("RemasterId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired() .IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_remaster_entity_id"); .HasConstraintName("fk_legacy_remasters_entities_remaster_id");
b.Navigation("LegacyEntity"); b.Navigation("LegacyEntity");
@@ -2638,6 +2599,10 @@ namespace Pf2eModel.Migrations
b.Navigation("Externals"); b.Navigation("Externals");
b.Navigation("LegacyTransferEntities");
b.Navigation("RemasterTransferEntities");
b.Navigation("Sources"); b.Navigation("Sources");
}); });
@@ -316,36 +316,20 @@ namespace Pf2eModel.Migrations
columns: table => new columns: table => new
{ {
legacy_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор сущности"), legacy_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор сущности"),
remaster_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор цели"), remaster_id = table.Column<int>(type: "integer", nullable: false, comment: "Идентификатор цели")
legacy_entity_id = table.Column<int>(type: "integer", nullable: false),
remaster_entity_id = table.Column<int>(type: "integer", nullable: false),
legacy_entities_id = table.Column<int>(type: "integer", nullable: false),
remaster_entities_id = table.Column<int>(type: "integer", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
table.PrimaryKey("pk_legacy_remasters", x => new { x.legacy_id, x.remaster_id }); table.PrimaryKey("pk_legacy_remasters", x => new { x.legacy_id, x.remaster_id });
table.ForeignKey( table.ForeignKey(
name: "fk_legacy_remasters_entities_legacy_entities_id", name: "fk_legacy_remasters_entities_legacy_id",
column: x => x.legacy_entities_id, column: x => x.legacy_id,
principalTable: "entities", principalTable: "entities",
principalColumn: "id", principalColumn: "id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "fk_legacy_remasters_entities_legacy_entity_id", name: "fk_legacy_remasters_entities_remaster_id",
column: x => x.legacy_entity_id, column: x => x.remaster_id,
principalTable: "entities",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_legacy_remasters_entities_remaster_entities_id",
column: x => x.remaster_entities_id,
principalTable: "entities",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_legacy_remasters_entities_remaster_entity_id",
column: x => x.remaster_entity_id,
principalTable: "entities", principalTable: "entities",
principalColumn: "id", principalColumn: "id",
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
@@ -1362,24 +1346,9 @@ namespace Pf2eModel.Migrations
column: "entity_id"); column: "entity_id");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "ix_legacy_remasters_legacy_entities_id", name: "ix_legacy_remasters_remaster_id",
table: "legacy_remasters", table: "legacy_remasters",
column: "legacy_entities_id"); column: "remaster_id");
migrationBuilder.CreateIndex(
name: "ix_legacy_remasters_legacy_entity_id",
table: "legacy_remasters",
column: "legacy_entity_id");
migrationBuilder.CreateIndex(
name: "ix_legacy_remasters_remaster_entities_id",
table: "legacy_remasters",
column: "remaster_entities_id");
migrationBuilder.CreateIndex(
name: "ix_legacy_remasters_remaster_entity_id",
table: "legacy_remasters",
column: "remaster_entity_id");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "ix_ritual_checks_ritual_id", name: "ix_ritual_checks_ritual_id",
@@ -285,36 +285,11 @@ namespace Pf2eModel.Migrations
.HasColumnOrder(2) .HasColumnOrder(2)
.HasComment("Идентификатор цели"); .HasComment("Идентификатор цели");
b.Property<int>("LegacyEntitiesId")
.HasColumnType("integer")
.HasColumnName("legacy_entities_id");
b.Property<int>("LegacyEntityId")
.HasColumnType("integer")
.HasColumnName("legacy_entity_id");
b.Property<int>("RemasterEntitiesId")
.HasColumnType("integer")
.HasColumnName("remaster_entities_id");
b.Property<int>("RemasterEntityId")
.HasColumnType("integer")
.HasColumnName("remaster_entity_id");
b.HasKey("LegacyId", "RemasterId") b.HasKey("LegacyId", "RemasterId")
.HasName("pk_legacy_remasters"); .HasName("pk_legacy_remasters");
b.HasIndex("LegacyEntitiesId") b.HasIndex("RemasterId")
.HasDatabaseName("ix_legacy_remasters_legacy_entities_id"); .HasDatabaseName("ix_legacy_remasters_remaster_id");
b.HasIndex("LegacyEntityId")
.HasDatabaseName("ix_legacy_remasters_legacy_entity_id");
b.HasIndex("RemasterEntitiesId")
.HasDatabaseName("ix_legacy_remasters_remaster_entities_id");
b.HasIndex("RemasterEntityId")
.HasDatabaseName("ix_legacy_remasters_remaster_entity_id");
b.ToTable("legacy_remasters", (string)null); b.ToTable("legacy_remasters", (string)null);
}); });
@@ -1970,33 +1945,19 @@ namespace Pf2eModel.Migrations
modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b => modelBuilder.Entity("Pf2eModel.Model.Base.LegacyRemaster", b =>
{ {
b.HasOne("Pf2eModel.Model.Base.Entity", null)
.WithMany()
.HasForeignKey("LegacyEntitiesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_legacy_entities_id");
b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity") b.HasOne("Pf2eModel.Model.Base.Entity", "LegacyEntity")
.WithMany() .WithMany("LegacyTransferEntities")
.HasForeignKey("LegacyEntityId") .HasForeignKey("LegacyId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired() .IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_legacy_entity_id"); .HasConstraintName("fk_legacy_remasters_entities_legacy_id");
b.HasOne("Pf2eModel.Model.Base.Entity", null)
.WithMany()
.HasForeignKey("RemasterEntitiesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_remaster_entities_id");
b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity") b.HasOne("Pf2eModel.Model.Base.Entity", "RemasterEntity")
.WithMany() .WithMany("RemasterTransferEntities")
.HasForeignKey("RemasterEntityId") .HasForeignKey("RemasterId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired() .IsRequired()
.HasConstraintName("fk_legacy_remasters_entities_remaster_entity_id"); .HasConstraintName("fk_legacy_remasters_entities_remaster_id");
b.Navigation("LegacyEntity"); b.Navigation("LegacyEntity");
@@ -2635,6 +2596,10 @@ namespace Pf2eModel.Migrations
b.Navigation("Externals"); b.Navigation("Externals");
b.Navigation("LegacyTransferEntities");
b.Navigation("RemasterTransferEntities");
b.Navigation("Sources"); b.Navigation("Sources");
}); });
+10
View File
@@ -110,8 +110,18 @@ public class Entity
/// </summary> /// </summary>
public ICollection<Entity> LegacyEntities { get; set; } = []; public ICollection<Entity> LegacyEntities { get; set; } = [];
/// <summary>
/// Коллекция переходных объектов для устаревших сущностей.
/// </summary>
public ICollection<LegacyRemaster> LegacyTransferEntities { get; set; } = [];
/// <summary> /// <summary>
/// Коллекция обновлённых сущностей. /// Коллекция обновлённых сущностей.
/// </summary> /// </summary>
public ICollection<Entity> RemasterEntities { get; set; } = []; public ICollection<Entity> RemasterEntities { get; set; } = [];
/// <summary>
/// Коллекция переходных объектов для обновлённых сущностей.
/// </summary>
public ICollection<LegacyRemaster> RemasterTransferEntities { get; set; } = [];
} }
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
namespace Pf2eModel.Model.Base.Source; namespace Pf2eModel.Model.Base.Source;
@@ -50,6 +51,7 @@ public class EntitySource
/// <summary> /// <summary>
/// Сущность, к которой относится источник. /// Сущность, к которой относится источник.
/// </summary> /// </summary>
[JsonIgnore]
public Entity Entity { get; set; } = null!; public Entity Entity { get; set; } = null!;
/// <summary> /// <summary>
+2
View File
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Pf2eModel.Model.Enum; using Pf2eModel.Model.Enum;
namespace Pf2eModel.Model.Base.Source; namespace Pf2eModel.Model.Base.Source;
@@ -44,5 +45,6 @@ public class Source
/// <summary> /// <summary>
/// Связанные сущности. /// Связанные сущности.
/// </summary> /// </summary>
[JsonIgnore]
public ICollection<EntitySource> EntitySources { get; set; } = []; public ICollection<EntitySource> EntitySources { get; set; } = [];
} }
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
namespace Pf2eModel.Model.Base.Targets; namespace Pf2eModel.Model.Base.Targets;
@@ -45,5 +46,6 @@ public class ExternalTarget
/// <summary> /// <summary>
/// Коллекция сущностей, которые ссылаются на эту цель. /// Коллекция сущностей, которые ссылаются на эту цель.
/// </summary> /// </summary>
[JsonIgnore]
public ICollection<EntityExternal> EntityExternals { get; set; } = []; public ICollection<EntityExternal> EntityExternals { get; set; } = [];
} }
+8 -6
View File
@@ -123,12 +123,14 @@ public partial class Pf2eDbContext
.HasMany(e => e.LegacyEntities) .HasMany(e => e.LegacyEntities)
.WithMany(e => e.RemasterEntities) .WithMany(e => e.RemasterEntities)
.UsingEntity<LegacyRemaster>( .UsingEntity<LegacyRemaster>(
//l => l =>
// l.HasOne(lr => lr.LegacyEntity).WithMany().HasForeignKey(lr => lr.LegacyId), l.HasOne(lr => lr.LegacyEntity)
//r => .WithMany(e => e.LegacyTransferEntities)
// r.HasOne(lr => lr.RemasterEntity) .HasForeignKey(lr => lr.LegacyId),
// .WithMany() r =>
// .HasForeignKey(lr => lr.RemasterId) r.HasOne(lr => lr.RemasterEntity)
.WithMany(e => e.RemasterTransferEntities)
.HasForeignKey(lr => lr.RemasterId)
); );
}); });