Отказ от отдельной легаси-сущности
This commit is contained in:
+14
-18
@@ -38,7 +38,7 @@ partial class EntityViewForm
|
||||
DescriptionTextBox = new TextBox();
|
||||
DatabaseViewer = new DatabaseViewerControl();
|
||||
EntityTreeViewerControl = new EntityTreeViewerControl();
|
||||
MainMenuStrip = new MenuStrip();
|
||||
MenuStrip = new MenuStrip();
|
||||
FileToolStripMenuItem = new ToolStripMenuItem();
|
||||
ExitToolStripMenuItem = new ToolStripMenuItem();
|
||||
WindowsToolStripMenuItem = new ToolStripMenuItem();
|
||||
@@ -54,7 +54,7 @@ partial class EntityViewForm
|
||||
((System.ComponentModel.ISupportInitialize)ResultSplitContainer).BeginInit();
|
||||
ResultSplitContainer.Panel2.SuspendLayout();
|
||||
ResultSplitContainer.SuspendLayout();
|
||||
MainMenuStrip.SuspendLayout();
|
||||
MenuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// RootSplitContainer
|
||||
@@ -110,10 +110,6 @@ partial class EntityViewForm
|
||||
ResultSplitContainer.Location = new Point(0, 0);
|
||||
ResultSplitContainer.Name = "ResultSplitContainer";
|
||||
//
|
||||
// ResultSplitContainer.Panel1
|
||||
//
|
||||
ResultSplitContainer.Panel1.Controls.Add(EntityTreeViewerControl);
|
||||
//
|
||||
// ResultSplitContainer.Panel2
|
||||
//
|
||||
ResultSplitContainer.Panel2.Controls.Add(DescriptionTextBox);
|
||||
@@ -156,14 +152,14 @@ partial class EntityViewForm
|
||||
EntityTreeViewerControl.TabIndex = 0;
|
||||
EntityTreeViewerControl.TypeFontSize = 7F;
|
||||
//
|
||||
// MainMenuStrip
|
||||
// MenuStrip
|
||||
//
|
||||
MainMenuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, WindowsToolStripMenuItem });
|
||||
MainMenuStrip.Location = new Point(0, 0);
|
||||
MainMenuStrip.Name = "MainMenuStrip";
|
||||
MainMenuStrip.Size = new Size(1384, 24);
|
||||
MainMenuStrip.TabIndex = 1;
|
||||
MainMenuStrip.Text = "menuStrip1";
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, WindowsToolStripMenuItem });
|
||||
MenuStrip.Location = new Point(0, 0);
|
||||
MenuStrip.Name = "MainMenuStrip";
|
||||
MenuStrip.Size = new Size(1384, 24);
|
||||
MenuStrip.TabIndex = 1;
|
||||
MenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
@@ -175,7 +171,7 @@ partial class EntityViewForm
|
||||
// ExitToolStripMenuItem
|
||||
//
|
||||
ExitToolStripMenuItem.Name = "ExitToolStripMenuItem";
|
||||
ExitToolStripMenuItem.Size = new Size(180, 22);
|
||||
ExitToolStripMenuItem.Size = new Size(109, 22);
|
||||
ExitToolStripMenuItem.Text = "Выход";
|
||||
ExitToolStripMenuItem.Click += ExitToolStripMenuItem_Click;
|
||||
//
|
||||
@@ -206,7 +202,7 @@ partial class EntityViewForm
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1384, 861);
|
||||
Controls.Add(RootSplitContainer);
|
||||
Controls.Add(MainMenuStrip);
|
||||
Controls.Add(MenuStrip);
|
||||
Name = "EntityViewForm";
|
||||
Text = "DataBaseViewer";
|
||||
RootSplitContainer.Panel1.ResumeLayout(false);
|
||||
@@ -220,8 +216,8 @@ partial class EntityViewForm
|
||||
ResultSplitContainer.Panel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)ResultSplitContainer).EndInit();
|
||||
ResultSplitContainer.ResumeLayout(false);
|
||||
MainMenuStrip.ResumeLayout(false);
|
||||
MainMenuStrip.PerformLayout();
|
||||
MenuStrip.ResumeLayout(false);
|
||||
MenuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@@ -235,7 +231,7 @@ partial class EntityViewForm
|
||||
private TextBox DescriptionTextBox;
|
||||
private EntityTreeViewerControl EntityTreeViewerControl;
|
||||
private DatabaseViewerControl DatabaseViewer;
|
||||
private MenuStrip MainMenuStrip;
|
||||
private MenuStrip MenuStrip;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem ExitToolStripMenuItem;
|
||||
private ToolStripMenuItem WindowsToolStripMenuItem;
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="MainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="MenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
|
||||
+13
-13
@@ -36,7 +36,7 @@ partial class StartForm
|
||||
SelectAllButton = new Button();
|
||||
DeselectAllButton = new Button();
|
||||
StartButton = new Button();
|
||||
MainMenuStrip = new MenuStrip();
|
||||
MenuStrip = new MenuStrip();
|
||||
FileToolStripMenuItem = new ToolStripMenuItem();
|
||||
ExitToolStripMenuItem = new ToolStripMenuItem();
|
||||
WindowsToolStripMenuItem = new ToolStripMenuItem();
|
||||
@@ -49,7 +49,7 @@ partial class StartForm
|
||||
MainSplitContainer.SuspendLayout();
|
||||
PropertiesGroupBox.SuspendLayout();
|
||||
ProcessorsGroupBox.SuspendLayout();
|
||||
MainMenuStrip.SuspendLayout();
|
||||
MenuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// MainSplitContainer
|
||||
@@ -143,14 +143,14 @@ partial class StartForm
|
||||
StartButton.UseVisualStyleBackColor = true;
|
||||
StartButton.Click += StartButton_Click;
|
||||
//
|
||||
// MainMenuStrip
|
||||
// MenuStrip
|
||||
//
|
||||
MainMenuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, WindowsToolStripMenuItem, StartToolStripMenuItem });
|
||||
MainMenuStrip.Location = new Point(0, 0);
|
||||
MainMenuStrip.Name = "MainMenuStrip";
|
||||
MainMenuStrip.Size = new Size(931, 24);
|
||||
MainMenuStrip.TabIndex = 1;
|
||||
MainMenuStrip.Text = "menuStrip1";
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { FileToolStripMenuItem, WindowsToolStripMenuItem, StartToolStripMenuItem });
|
||||
MenuStrip.Location = new Point(0, 0);
|
||||
MenuStrip.Name = "MenuStrip";
|
||||
MenuStrip.Size = new Size(931, 24);
|
||||
MenuStrip.TabIndex = 1;
|
||||
MenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// FileToolStripMenuItem
|
||||
//
|
||||
@@ -200,7 +200,7 @@ partial class StartForm
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(931, 677);
|
||||
Controls.Add(MainSplitContainer);
|
||||
Controls.Add(MainMenuStrip);
|
||||
Controls.Add(MenuStrip);
|
||||
Name = "StartForm";
|
||||
Text = "Настройки импорта данных";
|
||||
Load += StartForm_Load;
|
||||
@@ -210,8 +210,8 @@ partial class StartForm
|
||||
MainSplitContainer.ResumeLayout(false);
|
||||
PropertiesGroupBox.ResumeLayout(false);
|
||||
ProcessorsGroupBox.ResumeLayout(false);
|
||||
MainMenuStrip.ResumeLayout(false);
|
||||
MainMenuStrip.PerformLayout();
|
||||
MenuStrip.ResumeLayout(false);
|
||||
MenuStrip.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@@ -226,7 +226,7 @@ partial class StartForm
|
||||
private Button SelectAllButton;
|
||||
private Button DeselectAllButton;
|
||||
private Controls.ProcessorCollectionControl ProcessorCollectionControl;
|
||||
private MenuStrip MainMenuStrip;
|
||||
private MenuStrip MenuStrip;
|
||||
private ToolStripMenuItem FileToolStripMenuItem;
|
||||
private ToolStripMenuItem ExitToolStripMenuItem;
|
||||
private ToolStripMenuItem WindowsToolStripMenuItem;
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="MainMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="MenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
-32
@@ -7,7 +7,6 @@ using Pf2eDataScrapper.Processors;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model;
|
||||
using Pf2eModel.Model.Base;
|
||||
using Pf2eModel.Model.Base.Legacy;
|
||||
using Pf2eModel.Model.Base.Source;
|
||||
using Pf2eModel.Model.Base.Targets;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
@@ -59,17 +58,10 @@ internal abstract class AbstractEntityProcessor(
|
||||
/// <inheritdoc/>
|
||||
public override void Process()
|
||||
{
|
||||
if (Input.GetOptional<JArray>("remaster_id") is not null)
|
||||
{
|
||||
throw new LegacyItemException(Input.GetOptional<string>("name", ""));
|
||||
}
|
||||
|
||||
AddEntity();
|
||||
AddSource();
|
||||
AddExternal();
|
||||
AddTraits();
|
||||
|
||||
AddLegacy();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -229,29 +221,5 @@ internal abstract class AbstractEntityProcessor(
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление устаревших сущностей.
|
||||
/// </summary>
|
||||
protected virtual void AddLegacy()
|
||||
{
|
||||
JArray? legacyIdArray = Input.GetOptional<JArray>("legacy_id");
|
||||
|
||||
if (legacyIdArray is null || legacyIdArray.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] legacyIds = legacyIdArray.ToArray().Select(t => t.ToString()).ToArray();
|
||||
List<LegacyEntity> legacyEntities = Context
|
||||
.LegacyEntityExternals.Where(lee => legacyIds.Contains(lee.ExternalId))
|
||||
.Select(lee => lee.LegacyEntity)
|
||||
.ToList();
|
||||
|
||||
foreach (LegacyEntity legacyEntity in legacyEntities)
|
||||
{
|
||||
Entity.LegacyEntities.Add(legacyEntity);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Pf2eDataScrapper.App;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
|
||||
using Pf2eDataScrapper.Processors;
|
||||
using Pf2eModel;
|
||||
using Pf2eModel.Model.Base.Legacy;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using StringHelper = Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers.StringHelper;
|
||||
|
||||
namespace Pf2eDataScrapper.Importers.Implementations.Aonprd.Processors.Common;
|
||||
|
||||
[ProcessorCollection(
|
||||
"aonprd:legacy",
|
||||
InnerType = null,
|
||||
CompendiumType = ProcessorCompendiumEnum.Aonprd,
|
||||
Description = "Создание ссылок на устаревшие сущности",
|
||||
Group = ProcessorGroupEnum.AonprdPreparation,
|
||||
Parallel = true
|
||||
)]
|
||||
[ProcessorDependencies(["aonprd:source", "aonprd:external"])]
|
||||
internal class LegacyProcessor(
|
||||
ProcessorInput input,
|
||||
AonprdBuilderGlobals globals,
|
||||
StringHelper stringHelper
|
||||
) : AbstractInputProcessor(input)
|
||||
{
|
||||
public Pf2eDbContext Context { get; } = new();
|
||||
public AonprdBuilderGlobals Globals { get; } = globals;
|
||||
public StringHelper StringHelper { get; } = stringHelper;
|
||||
|
||||
private LegacyEntity LegacyEntity { get; set; } = null!;
|
||||
|
||||
public override void Process()
|
||||
{
|
||||
if (Input.GetOptional<JArray>("remaster_id") is null)
|
||||
{
|
||||
throw new SilentSkipItemException();
|
||||
}
|
||||
|
||||
LegacyEntity = new()
|
||||
{
|
||||
Name = { [LocaleType.English] = Input.GetOptional<string>("name", "sidebar-29") },
|
||||
};
|
||||
|
||||
AddSource();
|
||||
AddExternal();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Генерация источников сущности.
|
||||
/// </summary>
|
||||
protected virtual void AddSource()
|
||||
{
|
||||
string[] sourceNames = Input
|
||||
.GetRequired<JArray>("source")
|
||||
.Select(token => token.ToString())
|
||||
.ToArray();
|
||||
|
||||
if (sourceNames.Length == 0)
|
||||
{
|
||||
throw new(
|
||||
$"Source for entity with id \"{LegacyEntity.Name[LocaleType.English]}\" "
|
||||
+ $"(Aonprd id \"{Input.GetRequired<string>("id")}\") is not found"
|
||||
);
|
||||
}
|
||||
/*
|
||||
Dictionary<string, int> sourceIds = Context
|
||||
.Sources.AsNoTracking()
|
||||
.Where(s => sourceNames.Contains(s.Name))
|
||||
.ToDictionary(s => s.Name, s => s.Id);
|
||||
*/
|
||||
foreach (string sourceName in sourceNames)
|
||||
{
|
||||
LegacyEntitySource entitySource = new()
|
||||
{
|
||||
LegacyEntity = LegacyEntity,
|
||||
SourceId = Globals.SourceIds[sourceName],
|
||||
Suffix = StringHelper.ResolveSource(Input.GetRequired<string>("source_markdown")),
|
||||
IsRemaster = Input.GetOptional<JArray>("legacy_id") is not null,
|
||||
};
|
||||
|
||||
Context.LegacyEntitySources.Add(entitySource);
|
||||
LegacyEntity.Sources.Add(entitySource);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Генерация внешних ссылок сущности.
|
||||
/// </summary>
|
||||
protected virtual void AddExternal()
|
||||
{
|
||||
LegacyEntityExternal external = new()
|
||||
{
|
||||
LegacyEntity = LegacyEntity,
|
||||
TargetId = Globals.AonprdTarget.Id,
|
||||
ExternalId = Input.GetRequired<string>("id"),
|
||||
Suffix = Input.GetRequired<string>("url"),
|
||||
Md5 = Input.Md5(),
|
||||
};
|
||||
|
||||
Context.LegacyEntityExternals.Add(external);
|
||||
}
|
||||
|
||||
public override void Save()
|
||||
{
|
||||
Context.LegacyEntities.Add(LegacyEntity);
|
||||
|
||||
Context.SaveChanges(false);
|
||||
Context.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
using Pf2eDataScrapper.Helpers;
|
||||
using Pf2eDataScrapper.Importers.Implementations.Aonprd.Helpers;
|
||||
using Pf2eDataScrapper.Processors;
|
||||
using Pf2eModel.Model.Base.Legacy;
|
||||
using Pf2eModel.Model.Common.I18n;
|
||||
using Pf2eModel.Model.Enum;
|
||||
using Pf2eModel.Model.Structure;
|
||||
@@ -37,11 +36,6 @@ internal class TraitProcessor(
|
||||
Context.Traits.Add(Object);
|
||||
|
||||
Globals.TraitIds[Entity.Name[LocaleType.English]] = Entity.Id;
|
||||
|
||||
foreach (LegacyEntity legacyEntity in Entity.LegacyEntities)
|
||||
{
|
||||
Globals.TraitIds[legacyEntity.Name[LocaleType.English]] = Entity.Id;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ internal abstract class FoundryEnAbstractProcessor(
|
||||
{
|
||||
Type = LocaleType.English,
|
||||
Alias = Entity.Group,
|
||||
EntityId = Entity.Id,
|
||||
LegacyId = Entity.Id,
|
||||
Entity = Entity
|
||||
};
|
||||
Context.EntityAliases.Add(alias);
|
||||
|
||||
Reference in New Issue
Block a user